Dreadnort
06-17-2003, 08:26 AM
Is there a way that an asp script can look in a csv file and count the number of rows or number of entries found under a colum
|
Click to See Complete Forum and Search --> : still looking for help Dreadnort 06-17-2003, 08:26 AM Is there a way that an asp script can look in a csv file and count the number of rows or number of entries found under a colum cmelnick 06-17-2003, 09:30 AM There is no built in method that will automatically parse a text file. It wouldn't be terribly difficult to write your own parsing methods. You could use something like this: Dim strPath, oFileSys, oCSVFile, myLine, myRecord, count strPath = Server.MapPath("/your/database.csv") Set oFileSys = Server.CreateObject("Scripting.FileSystemObject") Set oCSVFile = oFileSys.OpenTextFile(strPath, 1, False) count = 0 Do Until oCSVFile.EOF myLine = oCSVFile.ReadLine myRecord = Split(myLine, ",") ' This will give you an array with your table values in ' myRecord(0), myRecord(1)...etc ' UBound(myRecord) will give you number of columns count = count + 1 Loop ' count will give you number of rows. oCSBFile.Close (p.s. just typed this up, so I probably made a mistake or two...just an example) Dreadnort 06-17-2003, 09:43 AM i will take a look and see what i can do thanks cmelnick 06-17-2003, 09:59 AM You're welcome...if you need more help, I can take a look at your CSV file and help you with exact code. Just let me know. Send me an e-mail to cmelnick (at) bigfoot (dot) com if I am not on the board. cmelnick 06-17-2003, 10:17 AM Doh! Sorry, the line: Do Until oCSVFile.EOF should be Do Until oCSVFile.AtEndOfStream Sorry. Been working w/ ADODB too much :D Forgot how to parse a text file... webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |