+ Reply to Thread
Results 1 to 6 of 6

How To Reduce Commas When Exporting To .CSV

  1. #1
    Registered User
    Join Date
    11-16-2013
    Location
    Cydonia, Mars
    MS-Off Ver
    Excel 2007
    Posts
    2

    How To Reduce Commas When Exporting To .CSV

    I have Excel 2007.

    When I export a spreadsheet to a .CSV file I always end up with a large amount of unwanted commas at the end of each line.

    Is there a way to mark a cell as null? Or mark a cell as a line end?

    So that when exporting all the empty / unused spaces on any given line are not converted into commas?

    for example:

    Fred 1 2 3 4 5 6 7 8 9 10

    Bert 1 2 3 4

    When exported would look like:

    Fred,1,2,3,4,5,6,7,8,9,10
    Bert,1,2,3,4,,,,,,,

    If I could signal / mark the fifth cell on the Bert line as line end then I would not end up with all the unwanted commas.

    Thanks

    Darkspire

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How To Reduce Commas When Exporting To .CSV

    Not to be glib...but...why do you care about the additional commas?
    Any program reading the CSV file will simply see them as empty cells. Also, those commas indicate to whoever is reviewing the file that row data was not erroneously truncated.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    11-16-2013
    Location
    Cydonia, Mars
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: How To Reduce Commas When Exporting To .CSV

    I am writing data tables in Excel for a game that uses text files.

    One of the exported .CSV files is 367 lines, some of the lines have less data on and it can take up to 15-20 minutes to just go through the file and delete the extra commas every time I export to test, if not deleted the program will read the extra commas as data and throw an exception.

    Darkspire

  4. #4
    Registered User
    Join Date
    08-10-2011
    Location
    TX
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: How To Reduce Commas When Exporting To .CSV

    Try selecting the first column without data in it - holding SHIFT, select END and the RIGHT arrow - that should select all the columns. Then right-click and delete the "empty" columns. I think you just have some ghost data in those trailing cells which gets created as NULL when saving to CSV. Worth a shot.
    If I helped, click on the star below the post!

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How To Reduce Commas When Exporting To .CSV

    I faced that situation quite a while ago.
    Back then, I created a calculated CSV "field" in a single column to the right of the data area and copied the values to a separate sheet in the workbook. The formula built each CSV row according to the spec required for the receiving program. Some rows had fewer fields than others. When done, I exported that calculated sheet to a CSV file.

    That formula looked something like this:
    Please Login or Register  to view this content.
    Is that something you can work with?

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How To Reduce Commas When Exporting To .CSV

    Load the CSV file into NotePad then, use REPLACE and search for ,, and replace with nothing. This will get rid of all commas that are together without data between them.

    This is only good if there are not empty cells within your data rows and the commas are at the end.

    The good part is that all the commas that are together will be eliminated in one go for the entire document.

    Save the edited document as a CSV file.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 01-17-2014, 05:56 PM
  2. Replies: 1
    Last Post: 12-17-2013, 03:18 PM
  3. Replies: 3
    Last Post: 01-28-2010, 08:30 PM
  4. Exporting data in a column out of excel WITH commas
    By wowzers in forum Excel General
    Replies: 2
    Last Post: 12-19-2009, 10:00 PM
  5. Need to reduce my IFs
    By iturnrocks in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-08-2007, 07:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1