![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: May 2006
Posts: 51
Rep Power: 3
![]() |
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 ! |
|
|
|
|
|
#2 |
|
Professional Programmer
|
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 ! |
|
|
|
|
|
#3 |
|
Programmer
Join Date: May 2006
Posts: 51
Rep Power: 3
![]() |
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 ! |
|
|
|
|
|
#4 |
|
Professional Programmer
|
yeap.
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#5 |
|
Programmer
Join Date: May 2006
Posts: 51
Rep Power: 3
![]() |
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 ! |
|
|
|
|
|
#6 |
|
Programmer
Join Date: May 2006
Posts: 51
Rep Power: 3
![]() |
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 ! |
|
|
|
|
|
#7 |
|
Professional Programmer
|
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 ! |
|
|
|
|
|
#8 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 156
Rep Power: 4
![]() |
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)
|
|
|
|
|
|
#9 |
|
Hobbyist Programmer
|
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.. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |