CSVFileToArray + separator

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
joeka
Newbie
Posts: 2
Joined: Tue Jun 18, 2013 10:47 am

CSVFileToArray + separator

Post by joeka » Tue Jun 18, 2013 10:53 am

Hi
I live in a strange part of the World where we use . (dot) as decimal separator and , (comma) as thousand separator and ; (semicolon) as field separator. I have some lists, created in Excel which are quite big that I want to read with CSVFileToArray. The fields in a line are separated by ; (semicolon). Is there hope for me?
Regards
joeka/Joakim

BTW
I know I can:
- change the settings in Windows to other notations, but I rather not.
- do a serch and replace but then I get lost if there are some , (comma) in the text fields
- read the file by ReadLn and separate but this makes debuging impossible because of the size of the files
I also found a post about using "LET>DELIMITER=;" but it didn´t work for me

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jun 18, 2013 12:11 pm

. as decimal seperator and , as thousand separator is common. If that's strange then I also live in a strange world.

CSVFileToArray wants commas I'm afraid.

But it's easy enough to simply read in the file and parse directly:

Code: Select all

ReadFile>c:\temp\test.csv,fileData
Separate>fileData,CRLF,lines
Let>r=0
Repeat>r
  Let>r=r+1
  Let>this_line=lines_%r%
  Separate>this_line,;,fields
  MessageModal>%fields_1%, %fields_2%, %fields_3%
Until>r=lines_count
Alternatively use ADO/Excel.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

joeka
Newbie
Posts: 2
Joined: Tue Jun 18, 2013 10:47 am

Post by joeka » Tue Jun 18, 2013 1:55 pm

Thanks for your quick reply.

I have tried readline and separate alternativ in another script. The file I am reading is 25000 lines. When debuging it taks about 4 sek to execute each line in the script.
I gues it took so llong time because all the array variables has to be "updated" for each executed line in the script. I tried DIM the array but the varables where still visuable.
Is it possible to DIM the Array when the data is read by readline and then separated?
Or is it possible to DIM an Array in two dimensions?
I see that I can skip the CSV file and do the handeling with the Excel commands instead but what do you mean by ADO/Excel?

Will the DBQuery command work with a ; (semicolon) separated CSVFile?
Regards
joeka/Joakim

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jun 18, 2013 3:56 pm

You would probably have similar issue with CSVFileToArray since it also brings everything into an array in memory.

By ADO/Excel I mean what you said "do the handling with the Excel commands".

Yes, you can also use DBQuery.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts