PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 25 → Wx - Importar arquivo CSV - Procedure WS_ImportCSV
Wx - Importar arquivo CSV - Procedure WS_ImportCSV
Iniciado por adrianoboller, ago., 28 2015 8:36 PM - Sem resposta
Membro registado
3.659 mensagems
Popularité : +175 (223 votes)
Publicado em agosto, 28 2015 - 8:36 PM
Procedure WS_ImportCSV(sFullFileName is string)

sCsvSeparator is string = ";"
sCsvRow is string
nFileNum is int
nLoop, Total is int
nCol is int
nJumCol is int = 1

// Create a Table Control with the sufficient (more) column
//TableDeleteAll(TABLE_Table1)

nFileNum = fOpen(sFullFileName,foRead)
IF nFileNum = -1 THEN
Error("File not found!")
ELSE
LOOP
sCsvRow=fReadLine(nFileNum)
nCol=1
Total = Length(sCsvRow)
FOR nLoop = 1 TO Total
IF sCsvRow[[nLoop]] = sCsvSeparator THEN
sCsvRow[[nLoop]] = TAB
nCol ++
END
END
Info(sCsvRow)
//TableAdd(TABLE_Table1,sCsvRow)
IF sCsvRow = EOT THEN BREAK
END
fClose(nFileNum)
END