Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9730

Re: Program to read csv file

$
0
0

Variation of Manuel's good idea:

 

// dynamically build a datastore with 64 string columns for import

datastore lds

integer liCol, liColCount = 64

long lRow, lRC

string lsDW

string lsColA = ' column=(type=char(10000) name=col'

string lsColB = ' dbname="col'

string lsFileName

string lsCell

 

lsDW = 'release 12;datawindow() table('

for liCol = 1 to liColCount

       lsDW += lsColA + string ( liCol ) + lsColB + string ( liCol ) + '" )'

next

lsDW += ')'

 

lds = CREATE datastore

if lds.Create( lsDW ) < 0 then return

 

SetNull ( lsFileName )

lRC = lds.ImportFile ( lsFileName )

if lRC < 1 then return

 

for lRow = 1 TO lRC

  for liCol = 1 to liColCount

       lsCell = lds.GetItemString ( lRow , liCol )

       if not IsNull ( lsCell ) then

            // process here

       end if

  next

next


Viewing all articles
Browse latest Browse all 9730


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>