I'm new at this so please bear with me. I have a CSV file that contains about 500 rows and 50 columns. I need to keep all the rows but only keep columns 1,2,3,4,6,7. I've opened the CSV and stored each row as a single element in a one-dimensional array. What I need to do now is search through those array elements and remove everything except column 1,2,3,4,6,7. Am I approaching this problem correctly If so, how do I proceed I'm stuck.

Editing Array of string values from CSV file
ShadowOfTheBeast
Tanmaya
Thanks for the help. When I try to print the contents of the array, I get 500 values of System.Collections.Generic.List'1[System.String]. I tried a simple loop with Console::WriteLine(theArray
) (the light bulb is supposed to be an i inside []) and then I stuck a line in where the values are being added to the array Console::WriteLine(lineValues) to see what was being added to the array. I do get a number of elements as 7 and line count of 500. Since this is a List, how do I print the array values
Janet666
I'm not sure whether I'm answering for your question.
I think you can do the following
1. Read Single Line
2. Read values till 7th Column
3. Move to next line
4. Go step 1 till end of rows
mark aoki
Happy to help.
I'm afraid I can't speak from experience regarding books on the managed extensions to C++ (known as C++/CLI). If I were you, I'd start my search on the following urls:
Sticky faq in the C++ general forum, with some tips and links for books and resources:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=107484&SiteID=1
Amazon search for C++/CLI, sorted by sales count. May have helpful reviews:
http://www.amazon.com/s/ref=sr_st/104-2154958-2979945 keywords=C%2B%2B%2FCLI&page=1&rh=n%3A1000%2Ck%3AC%2B%2B%2FCLI&sort=salesrank&x=13&y=10
MSDN has pretty good examples of the techniques used in the code I gave you. Look up some of the functions, and browse from there.
Also, www.codeguru.com and www.codeproject.com are quite good sites, with tons of articles and tutorials. Definitely worth your time :)
Good luck!
Zach7
I adapted your sample code somewhat. This should get you further.
Michael Grau
bkizzy
C McQuade
Dave987654321
Can you show us the code
If you use a vector of vectors to store the elements of the file, you can do something very simple like this:
and that's all...
ZaaM IT
Here's what I have so far. I'm using Visual Studio 2005. The Console::WriteLine statement and cout statements are only so I can see if it put the data in the array. It will be removed.
#include <stdafx.h>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
using namespace System;
using namespace System::IO;
using namespace System::Collections;
int _tmain()
{
StreamReader^ reader;
int lineCount = 0;
reader = gcnew StreamReader("aaa.csv");
String^ data;
ArrayList^ theArray = gcnew ArrayList(500);
while (0<reader->Peek())
{
data = reader->ReadLine();
theArray->Add(data);
Console::WriteLine(theArray[lineCount]);
lineCount++;
}
cout << lineCount << endl;
return 0;
}