How to read csv file using php?

Read hyphenated value from csv file?

  • I am developing a small application where i upload data from csv into a sql DB. The csv file can have values with hyphens(-). It is possible that the value can be hyphen only. When i read the data from file using a dataadapter, the hyphen is read as '0'. But when i open the CSV using either excel or notepad, the value still is displayed as '-'. Please provide a solution.

  • Answer:

    System.Data.OleDb.OleDbDataReader ParseCSVFile = CSVFile.ExecuteReader(); while (ParseCSVFile.Read()) { string[] Line = new string[ParseCSVFile.FieldCount]; for (int i = 0; i < ParseCSVFile.FieldCount; i++) Line[i] = ParseCSVFile.GetValue(i).ToString(); (...)

senthil k at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.