Hi,
I have to modify an existing csv file.
the original csv file is like this e.g.
123456,DE,meier,23532,munich
325632,DE,winkler,32312,berlin
and so on
i then have to add fields to each line. Some fields have to be added before each line ansd some between the fields of the original. So the new csv looks like this for example
000161616,xxxxx,123456,DE,meier,23532,zzzzz,munich,yyyy
000161616,aaaa,325632,DE,winkler,32312,qqqq,berlin,mmmm
and so on.
Some fields to be added have always the same value and some are different.
After the fields are added, the "," should be replaced by "tab", as the target system does not accept any other csv-files than delimited by "tab".
Any idea how i can solve this.
Maybe you can give me a hint, how i can read the source file field by field and how i can write the target file field by field.
Best regards,
Matthias
adding fields to a CSV and converting the delimiter , to tab
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Look in the help file at the following topics:
Separate
ReadLn
WriteLn
StringReplace
With Separate you can very easily explode the line into separate variables, then all you need to do is use them in a new output line and you can order them how you like and use whatever delimiter you want.
Separate
ReadLn
WriteLn
StringReplace
With Separate you can very easily explode the line into separate variables, then all you need to do is use them in a new output line and you can order them how you like and use whatever delimiter you want.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thank you very much.
but how do enter the , as the delimiter in the seperate command?
I tried the following
Let>k=1
Label>start
ReadLn>c:\report\stock.txt,k,line
If>line=##EOF##,finish
Seperate>line,",",field
Let>k=k+1
Goto>start
Label>finish
My test source file has just 3 lines
"2342352345",6.00
"kqzw332225",10.00
"125325",1.00
After the first loop the watch list shows me the following field variables
",FIELD_1=
",FIELD_2=2342352345
",FIELD_3=,6.00
Any idea?
Best regards,
Matthias
but how do enter the , as the delimiter in the seperate command?
I tried the following
Let>k=1
Label>start
ReadLn>c:\report\stock.txt,k,line
If>line=##EOF##,finish
Seperate>line,",",field
Let>k=k+1
Goto>start
Label>finish
My test source file has just 3 lines
"2342352345",6.00
"kqzw332225",10.00
"125325",1.00
After the first loop the watch list shows me the following field variables
",FIELD_1=
",FIELD_2=2342352345
",FIELD_3=,6.00
Any idea?
Best regards,
Matthias
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Let>delimiter=,
Separate>line,delimiter,fields
Separate>line,delimiter,fields
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?