JustSomeone Posted September 23, 2014 Share Posted September 23, 2014 Hi again, Spent the day browsing the forum, searching and trying this and that i have a csv file, long aroung 8K lines, using "," as delimer. I need the 2nd colonum to a txt file, and no matter what i try i either get some odd array errors (i suspect the amount of lines causing errors) or some retarded read time (1 min for like 4 lines, wich is going to get a week to parse the entire file.) Suggestions please. <3 p.s. i have no my code, using examples from this forum but none seems to work with so large files. Link to comment Share on other sites More sharing options...
jchd Posted September 23, 2014 Share Posted September 23, 2014 8K lines isn't large, by far. Can you post a sample of few typical lines so we can propose something way faster than what you have tried? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
JustSomeone Posted September 23, 2014 Author Share Posted September 23, 2014 example from the csv "Automated Reminder:blabla","SomeName <Some@email.com>","to@email.com",Date,*, i need the "SomeName <some@email.com>", possibly without the quotes. Sometimes, there is no name, only <email>. Link to comment Share on other sites More sharing options...
Solution jchd Posted September 23, 2014 Solution Share Posted September 23, 2014 Does that fit your needs? #include <Array.au3> ; sample inline data. Local $sTest = _ '"Automated Reminder:blabla","SomeName <Some@email.com>","to@email.com",Date,*,' & @CRLF & _ '"Automated Reminder:blablabis","SomeOtherName <Somebody@gmail.com>","to@email.com",Date,*,' & @CRLF & _ '"Automated Reminder:blablater","<SomeoneElse@email.com>","to@email.com",Date,*,' & @CRLF ; use this for real runs ;~ Local $sTest = FileRead("yourCSVfile.csv") Local $aRes = StringRegExp($sTest, '(?m)^"[^"]*","([^"]*)"', 3) _ArrayDisplay($aRes) JustSomeone 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
mikell Posted September 23, 2014 Share Posted September 23, 2014 Generic try ? #Include <Array.au3> $file = FileRead("1.csv") $res = StringRegExp($file, '.*?,"?([^",\r\n]*).*\R', 3) _ArrayDisplay($res) JustSomeone 1 Link to comment Share on other sites More sharing options...
JustSomeone Posted September 23, 2014 Author Share Posted September 23, 2014 (edited) Yes, both solutions work fine, thanks. EDIT: browsing trough the csv, i see some of the emails don't contain <>, because there is no name before that. Is it bad idea to manually search for "<" (i don't need the ">" ) and if it does not exist to add it then continue the things i do to the results, or there is some other smart way of doing it? Edited September 23, 2014 by JustSomeone Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now