Welcome to WebmasterWorld Guest from 54.197.156.64

Forum Moderators: ocean10000

Message Too Old, No Replies

Script To Read Certain Columns In Local CSV File With Classic ASP IIS

     
1:36 pm on Aug 17, 2011 (gmt 0)

New User

5+ Year Member

joined:Aug 17, 2011
posts:2
votes: 0


I have a CSV file dumped from a financial package which I need to extract some values from for use on an ASP page. Iíve managed to get a script to just read the entire file but thatís about it as I am pretty much clueless with ASP. All I need is the lines starting with 4000 to 4002 and then only the first, second and fourth column placed into variables that I can use later for some descriptions and calculations. Iíve included below an example of how the CSV file looks which is only 155 lines long but I only need the values from three of them.

"4000","Sales","4","-5454","1","0","0","0","0","0","0",
"0","0","0","0","0","0","0","0","0","0","0","0","0","0"
,"0","0","0","0","0","0","0","0","0","0","0","0","0","0"
,"0","0","0","0","0","0","0","0","0","0","0","0","0","0"
,"0","0","0","0","0","0","0","0","0","0","0","0","0","0"
,"0","0","0","0","0","0","0","0","0","0","0","0","0","0"
,"0","0","0","0","0","0","0","0","0","-5454","0","0","0"
,"0","0","0","0","0","0","0","0","0","0","0","0","0","0"
,"0","0","0","0","0","0","0","0","0","0","-5454"

So from this line I would like 4000, Sales and -5454 put into variables that I can use later on. The CSV file has no header.

Thanks in advanced.

[edited by: Ocean10000 at 3:19 am (utc) on Aug 23, 2011]
[edit reason] Break the line, so it wraped. [/edit]

3:42 am on Aug 21, 2011 (gmt 0)

Full Member

10+ Year Member

joined:May 14, 2001
posts:262
votes: 0


Just open the file, and create a counter. Loop through the file with ReadLine() and increment your counter each time. If you are on the line(s) that you want, then use split(line, ",") and then access the array elements that you want from that line.
9:39 am on Aug 22, 2011 (gmt 0)

New User

5+ Year Member

joined:Aug 17, 2011
posts:2
votes: 0


Do you have an example of this code as I am unfamilar with ASP?
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members