Jump to content

parsing VERY long csv file


 Share

Go to solution Solved by jchd,

Recommended Posts

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

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 here
RegExp tutorial: enough to get started
PCRE 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

  • Solution

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)

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 here
RegExp tutorial: enough to get started
PCRE 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

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 by JustSomeone
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...