Thread: .cvs file

  1. #1
    Registered User
    Join Date
    Aug 2019
    Posts
    4

    .cvs file

    hi i was wondering how to import a .csv file and save it to a memory buffer of doubles and print the contents of the .cvs file

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Find a C library for parsing files/strings in CSV formats.

    If you're only talking about a specific CSV format that has a fixed number of floating point values per line to be stored as doubles, then fscanf might be good enough.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    A CSV file format is quite simple, after all it stands for "Comma Separated Values". The first row is typically the names of the different columns, and all of the following rows are data. Remember that it may not only contain numbers.

    A word of caution though, CSV files are... inconsistent when it comes to line endings. Some use '\n', others use '\r\n' and others still just use '\r'. In the last case, I don't know if C converts it to a '\n' or not.
    Devoted my life to programming...

  4. #4
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    Quote Originally Posted by GReaper View Post
    A CSV file format is quite simple, after all it stands for "Comma Separated Values".
    Not as simple as it sounds, refer to this wikipedia post and the RFC 4180.
    I think the recommendation of @laserlight makes sense, unless someone is interested in createing its own set of routines...

  5. #5
    Registered User catacombs's Avatar
    Join Date
    May 2019
    Location
    /home/
    Posts
    81
    Is a .cvs file what the pharmacy uses to print the really, really long receipts?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2017, 10:48 AM
  2. Replies: 6
    Last Post: 12-28-2015, 03:36 AM
  3. Replies: 3
    Last Post: 11-28-2012, 09:16 AM
  4. Replies: 11
    Last Post: 09-25-2011, 12:22 AM
  5. Replies: 4
    Last Post: 07-06-2006, 02:53 AM

Tags for this Thread