Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi folks,

i am pretty new in developing applications in visual c#. i read some books, browsed some online tutorials and did some courses.
now i am facing my first project and somehow i am struggling around since a few days.
i´d really appreciate it if someone could point me to the right direction by answering to my post/question here. i am not sure if i´m on the correct path in solving my exercise.

task
i have to different csv files which represent my data (source: some measuring systems).
the content of both files should be loaded into my c#-program.
after some cleanup (deleting some rows and columns which should match some criteria) i want to merge both contents into one view / list / datagrid.
by selecting some checkboxes etc. the displayed content should be filtered and finally it should be save into a csv or exported to MS Excel for example.

current state
i am reading my csv files into two datagridviews.
after pressing a button the cleanup does not work perfectly as some rows are not correctly deleted from the view. after pressing the button again some more rows are deleted ... this is frustrating me at the moment.
if this would work ... my next step is to merge the content of both dataviewgrid into a single one which should be displayed in the c#-program.

well, i´ve asked some people ...
- one person told me to build a singleton class and to resolve my problem by using a bunch of lists
- another person told me to use arraylists which are dynamic

I am a little bit confused an the moment hence I think to miss the forest for the trees... can anyone infuse my little brain with the correct idea please?

thanks in advance,
andy

(ps. since i am not from a country where english is the native language please excuse my spelling)
Posted
Comments
BillWoodruff 29-Sep-14 3:51am    
"after some cleanup (deleting some rows and columns which should match some criteria) i want to merge both contents into one view / list / datagrid."

Hypothetical question: would it be better to massage/transform/clean-up the CSV data before it is loaded into the DataGridView ?

"after pressing a button the cleanup does not work perfectly as some rows are not correctly deleted from the view. after pressing the button again some more rows are deleted ... this is frustrating me at the moment."

Please show your code for the "cleanup."
Andy253 29-Sep-14 4:27am    
first of all thanks for your reply.
@ question: no, because this action has to be done by the c#-program.
well, the import into a datagridview is working fine but i am not sure if this is the best way to handle it. perhaps it should be bette to import those csv data into a arraylist?

here is the cleaning code - it should delete each row where the string test "MATCH" is found in the appropriate column:

void DeleteMatchEntries()
{
string sStringchecker;
int iVertikal = 0;
this.dataGridView1.Rows.RemoveAt(iVertikal);
dataGridView1.Update();

for (int m = 0; m < dataGridView1.Rows.Count - 1; m++)
{
sStringchecker = Convert.ToString(this.dataGridView1.Rows[iVertikal].Cells[19].Value);

if (sStringchecker != "MATCH")
{
iVertikal++;
}
else
{
dataGridView1.Rows.RemoveAt(iVertikal);
}
}
dataGridView1RUS.Update();

}
Sinisa Hajnal 29-Sep-14 4:02am    
Also, consider dumping whole CSV files data unchanged (except of course parsed into columns) into the tables in your database. Database is good tool for mass changing / merging data.

Write stored procedure for deletion of unwanted rows per your criteria. Then write update procedure to change what you want changed. Write import query which will insert the data in your final table joined as you see fit.

Simply call them in order.

Finally, show that prepared data to the user in the grid for manual changes.
Andy253 29-Sep-14 4:29am    
sound like a good and moreover logical idea, I´ve never worked with databases hence I need to figure out how the setup will look like.
I am afraid that realizing this in db-tech is to oversized ... I don´t wanna run a db server or something like that.

1 solution

Well, I think all those people who tried to help you before, while well meaning and all, were ...wrong

You don't just go from 'a problem' to writing code - there's steps in the middle, that go along the lines of analysis, design etc - from there you would have built a 'plan' and the steps required to test it - yes ?

You've clearly got some steps there

1) read file
2) display file
3) cleanup
4) merge files
5) filter
6) write

if you tested each step properly BEFORE you went onto the more complex steps like 'merge', then you wouldn't be so worried

I don't necessarily see how singleton classes, arraylists etc are going to help, unless you start ON PAPER, by breaking everything down to its smallest possible element, then thinking about solutions, data structures, tests, and then doing the implementation - no amount of technology is going to be able to unravel an incomplete thought process

bitte verzeihen Sie meine Manieren - ich möchte nicht unhöflich sein (isn't google great - I used to speak a little German, at least Im better than President Kennedy !)

Anyway - how does this help you ? .. I think you should break everything down on paper - then start a new project (don't throw away the old one) - build some little prototypes for example to help you get the logic for the cleanup correct .. once you have tested a 'phase/step' of the new program, then move onto the next bit ..
 
Share this answer
 
Comments
Andy253 29-Sep-14 4:38am    
Hi Garth,
you´re absolutely right. There are some points which require more attetion from my end - that´s true. But I already have something like an idea (flowchart) which is on paper. Over here I am searching for the correct tools for resolving my c#-program.
Nevertheless I am going to draw another plan before going to bed ;-)

ps.
JFK´s german language skills are perfect as he used to speak with a berlin accent as well :-)
Garth J Lancaster 7-Oct-14 6:01am    
did you find a solution ? depending on how much data you're talking about I had a thought

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900