How to? Parsing lines containing double quotes...

May 24, 2010
Northlake, Il
In a certain sense, I have a hard time believing I've never run into this before, and I also have a hard time believing that I even have to ask about it. But I've spent about 2 hours experimenting so far with no good results. So, to start, assume that I am reading data from a file whose lines take the following form:
Description for quoted field 1: "Quoted Field 1"   Description for quoted field 2: "Quoted Field 2" ...
What I want to do is quite trivial, at least in principle: Get the value of "Quoted Field 2".

I have done much experimentation without being able to use (at least reliably) the double-quote character as a field separator.

And if it's relevant, since there may be "unsafe" characters in the input data I'd like to use the "Safe" routines. But I will note that I haven't been able to get this to work consistently even if the "Safe" functions are not being used.
May 20, 2008
Syracuse, NY, USA
v:\> type desc.txt
Description for quoted field 1: "Quoted Field 1"
Description for quoted field 2: "Quoted Field 2"
v:\> do line in @desc.txt ( if %@index[%line,field 2] GE 0 echo %@word[5,%line] )
"Quoted Field 2"
May 20, 2008
Syracuse, NY, USA
Better ... refer to the last word in the line with
v:\> do line in @desc.txt (if %@index[%line,field 2] GE 0 echo %@word[-0,%line])
"Quoted Field 2"
May 24, 2010
Northlake, Il
Thank you, Vince. I'm not completely clear what the difference between the @Word... and @Field... functions is in this context, but the @Word... functions did it perfectly. (BTW, I simplified things a little bit my example in that which quoted string (of several) I wanted depended on the (unquoted) word(s) that preceded and "described" the quoted string that followed, so which actual quoted string I wanted depended on the presence/absence of certain "key" words in the descriptions that preceded each quoted string.) Again, thank you, Vince.
Similar threads
Thread starter Title Forum Replies Date
D Parsing an array variable to an array does not work Support 5
vefatica IF, @WMI, parsing? Support 7
M Command line parsing differences between cmd.exe and TCC Support 6
nickles Command name parsing of GNU compilers Support 13
J Python: TCC command line parsing removes '=' equal sign characters Support 4
H command line parsing question Support 5
cgunhouse One of the Focuses of V17 Beta Testing Should Be Command Line Parsing Support 1
Stefano Piccardi parsing issue in command GLOBAL Support 3
C CMD if parsing Support 2
M A probably stupid question about .btm file argument parsing... Support 6
S New "home" variable parsing issue Support 1
samintz Help with some parsing Support 6
vefatica Parsing error! Support 9
nikbackm Parsing problem? (IFF, "", &) Support 0
old coot Spurious errors (triggered by "for" construct?) when adding/removing "echo" lines Support 1
vefatica Continued lines (^) in a library routine? Support 5
R Lines between COMMENT & ENDCOMMENT not ignored Support 7
A TCMD - Dir Command puts out blank lines? Support 16
T FFind - can we display n number of lines after the find? Support 2
T WAD Difference between TCC and CMD in handling multi-command lines Support 6
JohnQSmith Weird DIR output (missing lines) Support 1
fpefpe Documentation Comment lines? Support 2
nickles Fixed Executing long command lines in a batch generates file name errors Support 16
B %@lines doesn't count last line without cr/lf at eof Support 1
nikbackm How to? Find duplicate lines in text file Support 0
S Documentation HELP nit: @LINES Support 5
B Select and run lines from Command Input panel? Support 1
D WAD New envars for @LINES are not hidden Support 8
T Documentation @LINE[CON,n] @LINES[CON] not documented (bug?) Support 4
Stefano Piccardi echoerr truncates long lines Support 9
M Just an out-of-curiosity question the List command vs. the @Lines function... Support 13
samintz How to? Pull out multiple matching lines Support 5
W Copy+Paste without breaking long lines as default? Support 1
L "for" in multiple lines Support 2
vefatica @LINES, long lines, TCC disappears Support 7
D Blank lines in jpstree.idx Support 3
T @Word from Lines with Pipes Support 3
vefatica @LINES[]? Support 1
J Extra blank lines during paste Support 6
vefatica How many lines are in this file? Support 17
nikbackm Trim last N lines from a file Support 6
T How do you echo lines with special characters to file? Support 4
B @lines: first line in the file is numbered 1 Support 0
R Reading an Unicode file with more than 8191 lines Support 1
A How to? Work with Filenames Containing Brackets "[" and "]" Support 2
greyfairer TCC Quotes needed for Arguments containing '='? Support 11
J Fixed Filename completion does not quote filenames containing ^ Support 1
nickles How to? Enumerate files containing '%' Support 2
D Function containing iff doesn't work in build 48 Support 11
Jay Sage Dealing With Filenames Containing Slash Character Support 5

Similar threads