Re: Importing files > 2GB

Author: Gérard Lochon

Posted: 2012-02-22 at 04:52:17

> I was thinking about saving to a CSV file again and then inserting into

> the MySQL table from that, with the fields fixed that had issue prior.

>

If wasting time is not a problem, you can use a loop to split the input file

into multiple cursors, then use them your way out :

[VFP]

*** creating a test file

SET TEXTMERGE ON noshow

SET TEXTMERGE TO testdata.txt

FOR i = 65 TO 90

\\<<REPLICATE(CHR(i),40)>>

\

ENDFOR

SET TEXTMERGE TO

*** appending the file in multiple cursors

*** we want to split into files made of nbby records, i.e. 10

nbby = 10

indname = 0

DO WHILE .T.

cpt = -1

** normally it should be cpt = 0, but the UDF mycount() is called one time

** before VFP executes the APPEND, for evaluation purpose (same way for

SELECT)

indname = indname+1

CREATE CURSOR ('work'+LTRIM(STR(indname))) (zon1 c(40))

APPEND FROM testdata.txt DELIMITED ;

FOR BETWEEN(mycount(), (indname-1)*nbby+1,indname*nbby)

IF _tally = 0

USE IN ('work'+LTRIM(STR(indname)))

EXIT

ENDIF

ENDDO

***

FUNCTION mycount

cpt = cpt+1

RETURN cpt

***

[/VFP]

Gérard.

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/profox

OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/7EB786FDD10D42509BE040B4E92E01E8@MuriellePC

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2012 Gérard Lochon