Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CSV files with comma and quotes
Message
From
15/11/2018 00:54:04
 
 
To
14/11/2018 16:25:59
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01663238
Message ID:
01663434
Views:
48
>>Hi All
>>
>>I have a CSV file which uses comma as the primary delimiter between fields. However, some fields might contain a comma (e.g. a description field) and the supplier provides those fields enclosed in quotes. For example:
>>
>>AAA,BBB,"XXX YYY, ZZZ",CCC,"X1, Y1, Z1",DDD,
>>
>>I cannot do an import on this CSV file as it contains too many fields. I need to parse the file, line by line.
>>
>>How can I get each field so that the result would be:
>>
>>Field 1: AAA
>>Field 2: BBB
>>Field 3: XXX YYY, ZZZ
>>Field 4: CCC
>>Field 5: X1, Y1, Z1
>>Field 6: DDD
>>
>>GETWORDNUM() works for fields separated with a comma but then it picks up individual sections in the description fields which are enclosed in quotes. I can write a manual parsing routine but was wondering if there was a faster way.
>>
>>TIA
>
>Hi Jos,
>PMFJI, I thought this was solved on day 1, but looks like not?
>
>IMHO it is a simple Append from ... type delimited. ie:
>
>
>Create Cursor myCursor (f1 c(50), f2 c(50), f3 c(50), f4 c(50), f5 c(50), f6 c(50))
>Append From myText.csv type delimited
>browse
>
>
>Result would be just like you wanted.

HI Cetin,

It is resolved but the discussion and suggestions went on a little. I cannot use the Append From because there are over 650 columns in the CSV file :) But we made an alternate solution.

Cheers
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Reply
Map
View

Click here to load this message in the networking platform