Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Querying CSV file

Querying CSV file

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpquestion
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Rajesh R Subramanian

    If i have an access database with a table called "USER" with fields ID, AGE, NAME, ADDRESS, and i want address of all users with age = 23, a simple sql query will do (SELECT * FROM USER WHERE blah blah).. But when I have data in a CSV File, how would i build this sql query? select * from what? :(( Any help or pointers in this direction is highly appreciated. Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

    T Offline
    T Offline
    ThatsAlok
    wrote on last edited by
    #2

    Rajesh R. Subramanian wrote:

    But when I have data in a CSV File, how would i build this sql query? select * from what?

    Hi Rajesh, csv file is nothing, just a comma seperated data and whole line denotes a record. for executing query AFAIK, you have to import that in access and proceed in similiar way you mentioned above.

    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

    cheers, Alok Gupta VC Forum Q&A :- I/ IV

    R 1 Reply Last reply
    0
    • R Rajesh R Subramanian

      If i have an access database with a table called "USER" with fields ID, AGE, NAME, ADDRESS, and i want address of all users with age = 23, a simple sql query will do (SELECT * FROM USER WHERE blah blah).. But when I have data in a CSV File, how would i build this sql query? select * from what? :(( Any help or pointers in this direction is highly appreciated. Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

      M Offline
      M Offline
      mbcvamsidhar
      wrote on last edited by
      #3

      Hai, CSV is just a text file...You cannot perform any operations on that. I think you have to Convert that text File in Table/Excel Format.. For this ..first you have to check ... 1.weather your file is variable length/Fixed length.... (...means weather your file is following any format..or not) 2.How it is parsed...(with coma,semicolon, space,tab etc) VamsiDhar.MBC SoftwareEngineer

      R 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        If i have an access database with a table called "USER" with fields ID, AGE, NAME, ADDRESS, and i want address of all users with age = 23, a simple sql query will do (SELECT * FROM USER WHERE blah blah).. But when I have data in a CSV File, how would i build this sql query? select * from what? :(( Any help or pointers in this direction is highly appreciated. Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

        B Offline
        B Offline
        basementman
        wrote on last edited by
        #4

        You can use the ODBC Text file driver to query the csv directly. However, it only gives you read access to the csv.  onwards and upwards...

        R 1 Reply Last reply
        0
        • T ThatsAlok

          Rajesh R. Subramanian wrote:

          But when I have data in a CSV File, how would i build this sql query? select * from what?

          Hi Rajesh, csv file is nothing, just a comma seperated data and whole line denotes a record. for executing query AFAIK, you have to import that in access and proceed in similiar way you mentioned above.

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #5

          Hi Alok,

          ThatsAlok wrote:

          csv file is nothing, just a comma seperated data

          Thanks for your reply, but I too know its Comma separated text data. My concern is that it would be faster to use CSV instead of Access database.

          ThatsAlok wrote:

          you have to import that in access and proceed in similiar way you mentioned above.

          Dude, I have exported values from Access and created the CSV because it would be faster. You are asking me to create a MDB out of it again :confused: Best Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

          T C 2 Replies Last reply
          0
          • M mbcvamsidhar

            Hai, CSV is just a text file...You cannot perform any operations on that. I think you have to Convert that text File in Table/Excel Format.. For this ..first you have to check ... 1.weather your file is variable length/Fixed length.... (...means weather your file is following any format..or not) 2.How it is parsed...(with coma,semicolon, space,tab etc) VamsiDhar.MBC SoftwareEngineer

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #6

            mbcvamsidhar wrote:

            CSV is just a text file...You cannot perform any operations on that.

            Sir, it is possible to perform operations on that. Atleast query operations. This can be done by using the xls driver. (select * from Sheet1 where blah blah).

            mbcvamsidhar wrote:

            2.How it is parsed...(with coma,semicolon, space,tab etc)

            CSV = Comma separated values. Parsed with comma. Regards and Thanks Rajesh R. Subramanian. You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

            M 1 Reply Last reply
            0
            • B basementman

              You can use the ODBC Text file driver to query the csv directly. However, it only gives you read access to the csv.  onwards and upwards...

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #7

              Yes master, I am using the same. But what would be the sql query format? SELECT * FROM what WHERE ... Thanks and Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

              B 1 Reply Last reply
              0
              • R Rajesh R Subramanian

                Hi Alok,

                ThatsAlok wrote:

                csv file is nothing, just a comma seperated data

                Thanks for your reply, but I too know its Comma separated text data. My concern is that it would be faster to use CSV instead of Access database.

                ThatsAlok wrote:

                you have to import that in access and proceed in similiar way you mentioned above.

                Dude, I have exported values from Access and created the CSV because it would be faster. You are asking me to create a MDB out of it again :confused: Best Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #8

                Rajesh R. Subramanian wrote:

                created the CSV because it would be faster.

                How Come ?:confused:

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta VC Forum Q&A :- I/ IV

                C 1 Reply Last reply
                0
                • T ThatsAlok

                  Rajesh R. Subramanian wrote:

                  created the CSV because it would be faster.

                  How Come ?:confused:

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                  cheers, Alok Gupta VC Forum Q&A :- I/ IV

                  C Offline
                  C Offline
                  color Aljechin
                  wrote on last edited by
                  #9

                  Rajesh is correct. 1. Create a CSV file by exporting 10000 records. 2. Perform data operation on your MDB and CSV file. 3. You will surely find csv to be faster since it is text based.

                  1 Reply Last reply
                  0
                  • R Rajesh R Subramanian

                    mbcvamsidhar wrote:

                    CSV is just a text file...You cannot perform any operations on that.

                    Sir, it is possible to perform operations on that. Atleast query operations. This can be done by using the xls driver. (select * from Sheet1 where blah blah).

                    mbcvamsidhar wrote:

                    2.How it is parsed...(with coma,semicolon, space,tab etc)

                    CSV = Comma separated values. Parsed with comma. Regards and Thanks Rajesh R. Subramanian. You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

                    M Offline
                    M Offline
                    mbcvamsidhar
                    wrote on last edited by
                    #10

                    Sir, it is possible to perform operations on that. Atleast query operations. This can be done by using the xls driver. (select * from Sheet1 where blah blah). Can you Give me the syntax ....how to connect..etc Thanks and Rgds VamsiDhar.MBC SoftwareEngineer

                    1 Reply Last reply
                    0
                    • R Rajesh R Subramanian

                      Hi Alok,

                      ThatsAlok wrote:

                      csv file is nothing, just a comma seperated data

                      Thanks for your reply, but I too know its Comma separated text data. My concern is that it would be faster to use CSV instead of Access database.

                      ThatsAlok wrote:

                      you have to import that in access and proceed in similiar way you mentioned above.

                      Dude, I have exported values from Access and created the CSV because it would be faster. You are asking me to create a MDB out of it again :confused: Best Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

                      C Offline
                      C Offline
                      color Aljechin
                      wrote on last edited by
                      #11

                      hi, Use OpenRowSet for performing data operations on .CSV files. I do not know if you could edit data, but you could query for sure. -- modified at 0:48 Thursday 29th December, 2005

                      R 1 Reply Last reply
                      0
                      • C color Aljechin

                        hi, Use OpenRowSet for performing data operations on .CSV files. I do not know if you could edit data, but you could query for sure. -- modified at 0:48 Thursday 29th December, 2005

                        R Offline
                        R Offline
                        Rajesh R Subramanian
                        wrote on last edited by
                        #12

                        Thank you so much. That was the keyword I was looking for. Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

                        1 Reply Last reply
                        0
                        • R Rajesh R Subramanian

                          Yes master, I am using the same. But what would be the sql query format? SELECT * FROM what WHERE ... Thanks and Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

                          B Offline
                          B Offline
                          basementman
                          wrote on last edited by
                          #13

                          Example assumes that the CSV file is C:\Data\MyData.csv: select * from C:\Data\MyData.csv Also, using the ODBC DSN config utility, you can define the names and data types of the columns in the file. If you do this, you can access the column names in your sql statement and get back converted data types. Otherwise, I believe it just returns columns named F1, F2, F3, etc, all being varchar(255).  onwards and upwards...  -- modified at 9:44 Thursday 29th December, 2005

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups