IonicWind Snippit Manager 2.xx Released! Install it on a memory stick and take it with you! With or without IWBasic!
Started by Jim Scott, January 03, 2007, 08:18:49 AM
0 Members and 1 Guest are viewing this topic.
Def pdb as PointerDef pTables as PointerDef hstmt as IntDef NumOfCols as IntDef TotalRows as IntStorageCount = 0TotalRows = 0OpenConsolepdb=dbConnect("Microsoft Text Driver (*.txt; *.csv)",GetStartPath,"")If pdb <> Null Print "Connection To Database Established" pTables = dbListTables(pdb) IF pTables <> NULL PRINT "Tables:" FOR temp = EACH pTables as STRING PRINT #temp PRINT "Cardinality:",dbCardinality(pdb,#temp) NEXT ListRemoveAll(pTables,TRUE) Else Print "No Tables to list" ENDIF hstmt = dbExecSQL(pdb,"SELECT * FROM WhosHereJim.txt") If hstmt <> Null NumOfCols = dbGetNumCols(hstmt) Print "Number of Columns in Dataset = ", NumOfCols Print "Cardinality of WhosHereJim.txt = ", dbCardinality(pdb,"WhosHereJim.txt") While dbGetNext(hstmt) <> Null TotalRows = TotalRows + 1 EndWhile dbFreeSQL(hstmt) EndIf dbDisconnect(pdb)Else Print "Connection Not Established"EndIfPrint "Number of Rows, Including header, = ", TotalRows + 1Print "Press any key to exit"Do:Until INKEY$ <> ""CloseConsoleEND
Connection To Database EstablishedTables:Number of Columns in Dataset = 12Cardinality of WhosHereJim.CSV = 117Number of Rows, Including header, = 152Press any key to exit
Quote from: Paul Turley on January 03, 2007, 07:34:50 PMIf I was forced to work with ASCII data in a text file I wouldn't use the database functions myself. Simpler to design a UDT to hold the records, read each line of the file into memory parsing using INSTR to locate the commas, and making my modifications using the UDT records.More control that way, and you can write it out anyway you wish.Another option ... snipped for brevityPaul.