+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23

Thread: Stubborn CSV file refuses to accept text format

  1. #1
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    Stubborn CSV file refuses to accept text format

    I have a CSV file that contains a zip code. Some zip codes beginning with zero appear as four digits instead of five. So I attempted to use the TEXT(R2,"00000") formula to force the format. Doing this produced the following result:

    1. Text appears correctly.
    2. File is verified as saved (including a change in the last modified date).
    3. When file is re-opened, changes are gone.

    I also attempted to format a column as text FIRST then paste the values of the formula into the new column and the format STILL did not hold. The only thing that forces it is a single quote, but I cannot leave a single quote in my zip codes.

    Any ideas?
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  2. #2
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    i've run into that same issue ... when the file is saved, after the formatting ... it's all fine. i am able to then import that into my database ... should i open the CSV again, all of the formatting is gone. i think it has something to do with converting from CSV to EXCEL when you open it. if i open the file with Notepad ++, the formatting actually still exists.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  3. #3
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    See: OL97: Postal Codes Import Incorrectly from Excel Workbook

    Basically it says that a zip code is stored as a number in Excel, but has the ZipCode format applied.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  4. #4
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    Hey guys - thanks for the quick reply!

    I've seen the number issue before, but what makes this particularly odd is that the formatting does not stick. I tried formatting to zip plus four, but since the majority of my zips are five digits, they came out as 00009-4031 instead of 94031-0000.

    Formatting to zip (without the dash four) has the same issue. Format disappears as soon as I save the file.

    This came up because I am uploading the file and the errors are caught on validation of the data. So the formatting is lost before the file is ever opened again. After I save the file, I try to upload it even before it is opened again and the same 'error' appears.

    I've been using Excel for more than 15 years, and I've never seen anything this stubborn!
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  5. #5
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    strange ... about the upload ... because i've been able to upload them with the format ... it's only when i reopen the file that i see it changed back. but i'm uploading to MySQL, wonder if that makes a difference.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  6. #6
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    Hmm - probably does. I suspect that the validation on this upload requires the file to be opened. This is for use as a mailing list, so the data has to be checked to insure valid zip codes.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  7. #7
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    I think you'll find it's losing the formatting because you're saving as CSV. A CSV file won't retain any formatting.

    Formatting as a zip code doesn't actually change the data in the cell, it just formats it to include a zero at the front of a 4 digit code. I think, but don't quote me on it, if you had the zip code as '01234 (ie starting with an apostrophe) it would keep the data as text.

  8. #8
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    Actually, you are right RR. I did try with a leading apostrophe and it does retain formatting in that limited case. But, since it will also presumably print said apostrophe, I cannot leave it there.

    Also - saving a properly formatted file from XLS to CSV causes a loss of formatting. Bummer
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  9. #9
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by Lauramc View Post
    Also - saving a properly formatted file from XLS to CSV causes a loss of formatting. Bummer
    That's the problem. Changing the formatting is just changing how it is displayed. The actual cell value is unaffected and a CSV won't save the formatting (what is displayed), it saves the value.

    I think I did something like create a new column next to the zipcode and then used this formula (assuming zipcode is in A1)
    Code:
    =if(len(A1)=4,"0"&A1,A1)
    
    Then I think saving as the csv will save the value from this formula.

    Hope that helps.

  10. #10
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    i beg to differ RR ...

    in order to import data into MySQL using Heid (which is the front end they use here), the file needs to be CSV and can't be EXCEL. when i format the field and save as CSV and import, I am getting the 5 characters, so it is saving it as a value.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Link Access text fields to MS Word text fields
    By Colper in forum Microsoft Access
    Replies: 8
    Last Post: May 5th, 2010, 04:08 PM
  2. [C#] How do I format text in a list box??
    By CCCSteve in forum .NET Development
    Replies: 15
    Last Post: April 16th, 2010, 03:23 PM
  3. DOS - Re-arrange file parts and build text file
    By tuxalot in forum Windows Scripting
    Replies: 0
    Last Post: December 31st, 2009, 01:50 PM
  4. Field format
    By Colper in forum Microsoft Access
    Replies: 33
    Last Post: December 3rd, 2009, 11:25 AM
  5. Save (open) MailAddresses to (from) text file
    By xxstephaniexx in forum .NET Development
    Replies: 2
    Last Post: August 4th, 2009, 05:44 AM

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

SEO by vBSEO