Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 7th, 2007, 05:23 AM
Registered User
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default CSV File & Vb.Net

Hi
I need to process a CSV file but the input csv file is having some unwanted data in the beginning like the name of the file,purpose of the file ,date when the file was generated.I have to create a SChema.INI file on the fly.But the presence of these additional lines in the beginning is causing many problems.I need to delete these first 5 rows from the file dynamically and then start the creation of ini file.But i am stuck!:(Please provide me with a solution.

Him Nish
 
Old December 7th, 2007, 08:43 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I imagine you have some loop that goes thru each line. Can't you just add some logic to skip the first X lines?

Can you post the relevant code so we may help you better?

-Peter
 
Old December 10th, 2007, 01:49 AM
Registered User
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i dont have any code for implementing this as yet..But i know that this is possible using File System Objects or File stream objects.
I tried this using file stream:by stream reader i read the file and using a loop and stream writer wrote the contents into another csv but this writing into another file is sometimes changing the datatype of some of the column as a result of which i m nt getting the expected results.so do u know how to achieve this using FSO?

Him Nish
 
Old December 10th, 2007, 10:49 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How can something change a datatype of data in a CSV file? Inherently, all data in a CSV files is textual.

Quote:
quote:
i dont have any code for implementing this as yet...
I tried this using file stream...
Well, which is it? Either you have tried it or you haven't. What code have you tried so far? Have you looked at the classes in System.IO? The System.IO.File class would be a good place to start.

-Peter
 
Old December 17th, 2007, 10:36 PM
Registered User
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you tried this:

Dim reader as new system.io.streamreader("yourCSVFile.CSV"), lineIn as string

For x as integer = 0 to 4
Reader.readLine
Next

While reader.peak <> -1
LineIn = reader.readline
'Do your processing on LineIn. If you call readline again, it'll go to the next line
Wend

reader.close


?? Though a cleaner way would be to write logic and deduce which lines are the bad lines, incase its more than 5, less, etc. Code like this can have undesired effects later if you change the file.

--Ryan Campbell
ryan@extremewebguy.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing csv file to SQL Server Using VB.Net ninel General .NET 0 August 8th, 2006 02:11 PM
vb.net & .udl file sachinbashetti Crystal Reports 0 May 23rd, 2005 02:00 AM
VB: Opening CSV file in Excel versus notepad codehappy VB How-To 6 April 22nd, 2005 10:59 AM
Getting VB.NET to load & update XML file kyma XML 0 March 19th, 2005 04:58 PM
how to edit/ update records/ rows of csv file vb thePervertedMonk VB How-To 1 December 10th, 2004 02:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.