homepage Welcome to WebmasterWorld Guest from 54.226.0.225
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

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




msg:4352666
 1:36 pm on Aug 17, 2011 (gmt 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]

 

bmcgee




msg:4353921
 3:42 am on Aug 21, 2011 (gmt 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.

horsewithnoname




msg:4354143
 9:39 am on Aug 22, 2011 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved