Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 24th, 2007, 4:48 AM   #1
teishu
Programmer
 
Join Date: May 2006
Posts: 51
Rep Power: 3 teishu is on a distinguished road
c# advice for csv files..

Hi, im writing a csv parser and was wondering what you think the best way of returnin the data is. its going to be a class that people can add to there projects. i was going to use arrays but then i remembered that you have to have set the size of the array before the app is compile so thats a problem.. How can i do you do you think ? The csv could have any amount of columns and any amount of lines...
__________________
AMD Athlon X2 4200+ -- Asus V3-M2V890 -- 2GB Kingston -- Vista Ultimate 32bit + Ubuntu 8.04
Intel C2D T5870 2.0GHZ -- Vostro 1510 -- 2048MB -- Windows XP SP2

ASCII stupid question, get a stupid ANSI !
teishu is offline   Reply With Quote
Old Jul 24th, 2007, 4:51 AM   #2
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 379
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
If the fixed size is the problem use : List<T> - it's the generic version of ArrayList. So that's that for the number of lines.
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Jul 24th, 2007, 5:02 AM   #3
teishu
Programmer
 
Join Date: May 2006
Posts: 51
Rep Power: 3 teishu is on a distinguished road
Does it work like this ?

List<int> blah = new List<int>();
blah.Add(1);
__________________
AMD Athlon X2 4200+ -- Asus V3-M2V890 -- 2GB Kingston -- Vista Ultimate 32bit + Ubuntu 8.04
Intel C2D T5870 2.0GHZ -- Vostro 1510 -- 2048MB -- Windows XP SP2

ASCII stupid question, get a stupid ANSI !
teishu is offline   Reply With Quote
Old Jul 24th, 2007, 5:06 AM   #4
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 379
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
yeap.
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Jul 24th, 2007, 5:09 AM   #5
teishu
Programmer
 
Join Date: May 2006
Posts: 51
Rep Power: 3 teishu is on a distinguished road
hmm, i take it i cant use it like this:

int totalcolumns = 5;
int count = 0;
while (count < totalcolumns)
{
List<int> count = new List<int>();
count++;
}



to have a list for each column...
__________________
AMD Athlon X2 4200+ -- Asus V3-M2V890 -- 2GB Kingston -- Vista Ultimate 32bit + Ubuntu 8.04
Intel C2D T5870 2.0GHZ -- Vostro 1510 -- 2048MB -- Windows XP SP2

ASCII stupid question, get a stupid ANSI !
teishu is offline   Reply With Quote
Old Jul 24th, 2007, 5:57 AM   #6
teishu
Programmer
 
Join Date: May 2006
Posts: 51
Rep Power: 3 teishu is on a distinguished road
could i have a list of arrays ?
__________________
AMD Athlon X2 4200+ -- Asus V3-M2V890 -- 2GB Kingston -- Vista Ultimate 32bit + Ubuntu 8.04
Intel C2D T5870 2.0GHZ -- Vostro 1510 -- 2048MB -- Windows XP SP2

ASCII stupid question, get a stupid ANSI !
teishu is offline   Reply With Quote
Old Jul 24th, 2007, 6:06 AM   #7
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 379
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
you sure can. You can have a list of lists like :
List<List<string>> xxx = new List<List<string>>();
so xxx[0] will return a List<string>.(that would be one row from the file.)
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Jul 24th, 2007, 8:13 PM   #8
Arla
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 156
Rep Power: 4 Arla is on a distinguished road
Personally I'd do it with ArrayList (when I say I'd do it with ArrayList, I mean that's what I did it with, I have both CSV pasers and CSV writers)
Arla is offline   Reply With Quote
Old Jul 24th, 2007, 8:49 PM   #9
john Wesley
Hobbyist Programmer
 
john Wesley's Avatar
 
Join Date: May 2006
Location: United Kingdom
Posts: 119
Rep Power: 3 john Wesley is on a distinguished road
Send a message via MSN to john Wesley Send a message via Yahoo to john Wesley
I agree that a strong-typed list is not neccesary unless explicitly called for, an ArrayList also has a dynamic length.

You could however, as you are talking of above, use generics to keep track of the column and value, but I guess you already have a structure for matching up memorised values already.
__________________
Mona Lisa must of had the highway blues you can tell by the way she smiles..
john Wesley is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I read .mbm (Multi BitMap) files? moondog Other Programming Languages 19 Aug 16th, 2007 8:59 PM
Unix commands compatible with Windows? titaniumdecoy Bash / Shell Scripting 7 Oct 5th, 2006 7:25 AM
Command Prompt SkyPioneer Coder's Corner Lounge 5 May 3rd, 2006 10:07 PM
Checking source codes of image, audio and video files on_auc C++ 3 Feb 21st, 2005 8:36 PM
shutil.copy corrupting files? TimL Python 0 Feb 20th, 2005 3:32 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC