FFIELDS from TextUtils

Hey @Charles Dye;
I would like to make a suggestion in regards to the FFIELDS command from the TextUtils plugin.

If possible, please add an option to separate fields at tabs (that is, @CHAR[9]).

I'm trying to use it against a database query, but the query only outputs with tab as the field separator.
Code:
odbc.exe -h "DSN=Banking32" "Select * from trans.dbf where acct_numb = 3500" |! ffields

3500.0  2020-12-07      A&W     14.68
3500.0  2020-12-08      A&W:A&W 29.78
3500.0  2020-12-14      Wendy's 15.8
3500.0  2020-12-14      Little Caesar's Pizza   23.71
3500.0  2020-12-14      A&W     15.9

Code:
00004F00  30 09 32 30 32 30 2D 31 32 2D 30 37 09 41 26 57    0.2020-12-07.A&W
00004F10  09 31 34 2E 36 38 09 0D 0A 33 35 30 30 2E 30 09    .14.68...3500.0.
00004F20  32 30 32 30 2D 31 32 2D 30 38 09 41 26 57 3A 41    2020-12-08.A&W:A
00004F30  26 57 09 32 39 2E 37 38 09 0D 0A 33 35 30 30 2E    &W.29.78...3500.
00004F40  30 09 32 30 32 30 2D 31 32 2D 31 34 09 57 65 6E    0.2020-12-14.Wen
00004F50  64 79 27 73 09 31 35 2E 38 09 0D 0A 33 35 30 30    dy's.15.8...3500
00004F60  2E 30 09 32 30 32 30 2D 31 32 2D 31 34 09 4C 69    .0.2020-12-14.Li
00004F70  74 74 6C 65 20 43 61 65 73 61 72 27 73 20 50 69    ttle Caesar's Pi
00004F80  7A 7A 61 09 32 33 2E 37 31 09 0D 0A 33 35 30 30    zza.23.71...3500

Thanks from Joe
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
My sense is that if tab are delimiters, they should act like commas, i.e. two successive tabs would imply an empty field between them. Is that how you think it should work?
 
Yepper, two successive tabs would imply an empty field between them.
Code:
315.0   2021-10-02      33.901L @ $1.539/L - 229,203km  52.17
315.0           Item Name               25.0
Code:
00002950  33 6B 6D 09 35 32 2E 31 37 09 0D 0A 33 31 35 2E    3km.52.17...315.
00002960  30 09 09 49 74 65 6D 20 4E 61 6D 65 09 09 32 35    0..Item Name..25
00002970  2E 30 0D 0A

Joe
 
Thankyou @Charles Dye

I've download TextUtils from http://prospero.unm.edu/dl/textutils.zip

Plugin /I returns Version: 0.82 Build 2

Here it is applied the same as in my original post;
Code:
odbc.exe -h "DSN=Banking32" "Select * from trans.dbf where acct_numb = 3500" |! ffields
3500.0     2020-12-07  A&W           14.68                
3500.0     2020-12-08  A&W:A&W       29.78                
3500.0     2020-12-14  Wendy's       15.8                 
3500.0     2020-12-14  Little        Caesar's   Pizza        23.71

It now seems to think that the first whitespace means a field separator. This is the same result I get when using the /W option.

Here's the Hex view after pipeing to ffields;

Code:
000090E0  2D 31 32 2D 30 37 20 20 41 26 57 20 20 20 20 20    -12-07  A&W     
000090F0  20 20 20 20 20 20 31 34 2E 36 38 20 20 20 20 20          14.68     
00009100  20 20 20 20 20 20 20 20 20 20 20 0D 0A 33 35 30               ..350
00009110  30 2E 30 20 20 20 20 20 32 30 32 30 2D 31 32 2D    0.0     2020-12-
00009120  30 38 20 20 41 26 57 3A 41 26 57 20 20 20 20 20    08  A&W:A&W     
00009130  20 20 32 39 2E 37 38 20 20 20 20 20 20 20 20 20      29.78         
00009140  20 20 20 20 20 20 20 0D 0A 33 35 30 30 2E 30 20           ..3500.0 
00009150  20 20 20 20 32 30 32 30 2D 31 32 2D 31 34 20 20        2020-12-14  
00009160  57 65 6E 64 79 27 73 20 20 20 20 20 20 20 31 35    Wendy's       15
00009170  2E 38 20 20 20 20 20 20 20 20 20 20 20 20 20 20    .8              
00009180  20 20 20 0D 0A 33 35 30 30 2E 30 20 20 20 20 20       ..3500.0     
00009190  32 30 32 30 2D 31 32 2D 31 34 20 20 4C 69 74 74    2020-12-14  Litt
000091A0  6C 65 20 20 20 20 20 20 20 20 43 61 65 73 61 72    le        Caesar
000091B0  27 73 20 20 20 50 69 7A 7A 61 20 20 20 20 20 20    's   Pizza

Joe
 
I am now!
Code:
3500.0     2020-12-08  A&W:A&W             29.78
3500.0     2020-12-14  Wendy's             15.8
3500.0     2020-12-14  Little Caesar's Pi  23.71
It's truncating the end of the field (in this case, missing the zza), so I tried the following;
Code:
odbc.exe -h "DSN=Banking32" "Select * from trans.dbf where acct_numb = 3500" |! ffields /t /F:$2=35L /p
...which fixes the truncated field, but no other columns are displayed.
(35 is the width of the field in my .dbf)
Code:
A&W:A&W                            
Wendy's                            
Little Caesar's Pizza

I tried using two formats;
Code:
/F:$0=4L /F:$2=35L
...but it seems to only allow one format, that is, the last format entered on the command line.

Joe
 
This works;
Code:
odbc.exe -h "DSN=Banking32" "Select * from trans.dbf where acct_numb = 3500" |! ffields /t /F:$0=4L$1=10L$2=35L$3=7R
...but there is no spacing between the columns.

Okay, this seems to work;
Code:
odbc.exe -h "DSN=Banking32" "Select * from trans.dbf where acct_numb = 3500" |! ffields /t /F:$0=8L$1=12L$2=35L$4=9R

I will try it on some of my other .DBF and .CSV files, and let you know how it goes.

Thanks!

Joe
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
This works;
Code:
odbc.exe -h "DSN=Banking32" "Select * from trans.dbf where acct_numb = 3500" |! ffields /t /F:$0=4L$1=10L$2=35L$3=7R
...but there is no spacing between the columns.

To put spaces into the format string — into pretty much any string — use double quotes:
Code:
odbc.exe -h "DSN=Banking32" "Select * from trans.dbf where acct_numb = 3500" |! ffields /t /F:"$0=4L  $1=10L  $2=35L  $3=7R"
 

Similar threads