• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1276
  • Last Modified:

Visual Studio 2010 - Import CSV data, data mine, show in form for user, then output as text

I am looking to grab either a txt, csv, and excel file(whichever would be easier I can get whichever format from the program we are getting it from), import this data in my VS2010 program(windows form or WPF), data mine this to pick out only certain pieces, then display to user, letting them add or edit, then output to a txt file.  What is the best way to do this nowadays?  
0
ITSuperman
Asked:
ITSuperman
2 Solutions
 
Éric MoreauSenior .Net ConsultantCommented:
the textfieldparser is an efficient way of parsing a text file: http://emoreau.com/Entries/Articles/2010/05/Do-you-know-the-TextFieldParser.aspx
0
 
Hawkvalley1Commented:
I like to import raw data in a datatable if it's contents are symmetrical (rows and columns). CSV example, but this could be txt as well if comma separated.

Dim dt As New DataTable
'add columns
dt.Columns.Add(<name of column>)
'repeat as needed

Using sr As New StreamReader(<path to file>)
  While Not sr.EndOfStream
     dt.Rows.Add(sr.Readline.Split(","c))
  End While
End Using

Open in new window


Then make LINQ queries to it and display the query. DataGridView are great for displaying datatables.    
 
0
 
ITSupermanAuthor Commented:
Thanks to you both for your help!  I am working on manipulating the data now into the form.  
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now