Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8486497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:57:40+00:00 2026-06-10T20:57:40+00:00

I am writing an application to process and upload a csv file to a

  • 0

I am writing an application to process and upload a csv file to a remote server.
The application needs to be fairly flexible, allowing custom mappings of columns.

The first big hurdle I’ve come to is with reading the file, many of the files have the data starting at row 5+ with some junk data at the top, example below:

Account: 123
----------
Date: 15/12/2011
----------
Type: Full
----------
Column1,Column2,Column3,Column4
Data1,Data2,Data3,Data4
Data1,Data2,Data3,Data4

Ideally I’d like a way to pick up the first line of data but this might be tricky.

I’m connecting to the file using Jet with the connection string:

If (_extension = ".csv") Then

                _excelconn.ConnectionString = String.Format( _
                    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}" & _
                    "; Extended Properties=""text;HDR=No;FMT=Delimited""", _directory)

End If

Then getting data via the code:

If ValidateAll() Then
            Try

                ConnectExcel() ' Opens connection to csv/excel file

                _excelcommand.CommandText = "SELECT * FROM [" & _excelsheets(_selsheet) & "]" ' Currently selected sheet, returns SELECT * FROM [1234#csv]
                _excelcommand.Connection = _excelconn

                _reader = _excelcommand.ExecuteReader()

                While _reader.Read()

                    'MsgBox(_reader(0).ToString)
                    'Dostuff

                End While

            Catch ex As Exception
                _errors.Add(ex.ToString)
                retval = -1
            End Try


        End If

This is falling over with an exception as I can’t access reader(2) for the first lines.

Is there any way in the connection string or in the SELECT statement to tell Jet to skip the first X rows of the sheet?
If not is there a way to only process the reader.Read() if the row number is higher than X?

I know it’s probably possible with reading the entire file to an array and parsing from there or by copying the file contents to a new csv file but if there is a way to avoid that and do it through jet/ado then I’d much prefer that!

(tagged sql as there might be an sql solution in the ado query)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:57:41+00:00Added an answer on June 10, 2026 at 8:57 pm

    Found the answer after a lot of experiments and searches, moved to a table adaptor, code below:

    Private _filepath As String
    Private _directory As String
    Private _filename As String
    Private _extension As String
    Private _selsheet As Integer
    Private _skiprows As Integer
    Private _data As New DataTable
    
    Private _excelconn As New OleDbConnection
    //Private _reader As OleDbDataReader
    Private _excelcommand As New OleDbCommand
    Private _excelta As New OleDbDataAdapter
    
    _excelcommand.CommandText = "SELECT * FROM [" & _excelsheets(_selsheet) & "]"
    _excelcommand.Connection = _excelconn
    
    _excelta.SelectCommand = _excelcommand
    _data = New DataTable
    _excelta.Fill(_skiprows, Int32.MaxValue, _data)
    
    
    For i = 0 To _data.Columns.Count - 1
        If _data.Rows(0).Item(i).ToString <> "" And IsNothing(_data.Columns(_data.Rows(0).Item(i).ToString)) Then
              _data.Columns.Item(i).ColumnName = _data.Rows(0).Item(i).ToString
        End If
    Next
    
    _data.Rows.RemoveAt(0) //removes first data row containing labels
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in the process of writing an application to suggest circular routes over OpenStreetMap
I'm currently in the process of writing a steganography application with Qt. I am
I am in the process of writing an enterprise-level application utilizing WCF and NetTCP
I'm writing a ASP.NET application to process user submitted zip files and limiting my
I'm writing an application in C# which needs to attach one of its own
I'm currently in the process of writing an application that has quite a number
I have an ASP.NET application which tracks statistics by creating and writing to custom
I am in the process of writing an application that processes a huge number
I am in the process of writing an application that communicates with several devices
I am in the process of writing an application in which I use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.