Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

CSV files

erikdudeerikdude NorwayPosts: 41New Users @
Hello!

I'm writing an iOS 8 app that allows you to export app data to a CSV file (to be added as a mail attachment). I've understood that the default delimiter used when reading the CSV file can vary (correct?), based on your regional settings - and was therefore wondering if it was possible to create a "universal" CSV file that could be read correctly using Excel, OpenOffice or other. The columns and rows will only contain "pure" text - no symbols.

Thank you!
Erik

Replies

  • baja_yubaja_yu San FranciscoPosts: 6,215Moderators, Registered Users Admin
  • RickSDKRickSDK Posts: 1,240Registered Users @ @ @ @
    if you simply create a text file with comma separated values, and name it with ".csv" extension, it should open properly in Excel.
  • erikdudeerikdude NorwayPosts: 41New Users @
    RickSDK wrote: »
    if you simply create a text file with comma separated values, and name it with ".csv" extension, it should open properly in Excel.

    Doesn't here, only with semicolons... hmm
  • C6Silver05C6Silver05 SeattlePosts: 632New Users @ @ @
    I assume this is because in Europe the comma has the meaning of a decimal point in the US. You are best off using a non-printable character like a TAB to avoid this and other anomalous data (fixed-width is the best but not practical here.)
  • erikdudeerikdude NorwayPosts: 41New Users @
    edited August 2015
    C6Silver05 wrote: »
    I assume this is because in Europe the comma has the meaning of a decimal point in the US. You are best off using a non-printable character like a TAB to avoid this and other anomalous data (fixed-width is the best but not practical here.)

    Indeed, I'm in Norway. Will TAB be detected as a delimiter on a world-wide basis by software like MS Excel and OpenOffice?
  • C6Silver05C6Silver05 SeattlePosts: 632New Users @ @ @
    erikdude wrote: »
    C6Silver05 wrote: »
    I assume this is because in Europe the comma has the meaning of a decimal point in the US. You are best off using a non-printable character like a TAB to avoid this and other anomalous data (fixed-width is the best but not practical here.)

    Indeed, I'm in Norway. Will TAB be detected as a delimiter on a world-wide basis by software like MS Excel and OpenOffice?

    Yes. Tab is a common delimiter. In fact outside of a "comma" it is probably the most widely used delimiter (from my experience).

  • RickSDKRickSDK Posts: 1,240Registered Users @ @ @ @
    if you use tabs, name it ".xls" and it will open properly with Excel. csv stands for "Comma Separated Values"
  • erikdudeerikdude NorwayPosts: 41New Users @
    RickSDK wrote: »
    if you use tabs, name it ".xls" and it will open properly with Excel. csv stands for "Comma Separated Values"

    This appears to be working, but excel displays a warning message about how the file might be damaged and that you should only trust files coming from sources you know. This might scare users.
  • dev666999dev666999 Posts: 3,620New Users @ @ @ @ @
    edited August 2015
    erikdude wrote: »
    RickSDK wrote: »
    if you use tabs, name it ".xls" and it will open properly with Excel. csv stands for "Comma Separated Values"

    This appears to be working, but excel displays a warning message about how the file might be damaged and that you should only trust files coming from sources you know. This might scare users.


    The Excel user may need to reset/loosen security to avoid that if caused by a Macro.

    If caused by OS X, that's a standard feature for software not recognized by OS X. The user then has to open preferences and accept the file.
  • BrianSlickBrianSlick Treadmill Desk Ninja Posts: 10,690Tutorial Authors, Registered Users @ @ @ @ @ @ @ @
    Giving a text file a "xls" extension does not convert that file into an Excel spreadsheet format. That's most likely the reason for the warning.

    I don't have Excel on this machine, but the last time I dealt with this stuff Excel offered a lot of options regarding what to use as a delimiter upon import. Pretty sure it could make an attempt with plain text files, too.

    So I would say that if you're going to use commas, use a "csv" extension. If you are going to use tabs, use a "txt" extension. Pretty sure Excel can work with it either way.
    Professional iOS App Development. Available for hire.
    BriTer Ideas LLC - WWW | Facebook | Twitter | LinkedIn

    BTIKit | SlickShopper 2 | Leave a PayPal donation
  • erikdudeerikdude NorwayPosts: 41New Users @
    edited August 2015
    BrianSlick wrote: »
    Giving a text file a "xls" extension does not convert that file into an Excel spreadsheet format. That's most likely the reason for the warning.

    I don't have Excel on this machine, but the last time I dealt with this stuff Excel offered a lot of options regarding what to use as a delimiter upon import. Pretty sure it could make an attempt with plain text files, too.

    So I would say that if you're going to use commas, use a "csv" extension. If you are going to use tabs, use a "txt" extension. Pretty sure Excel can work with it either way.

    Perhaps the best solution will be to use commas, and have the button in the app say something like "Export as CSV" and let the user know where they can get information on how to open it?
Sign In or Register to comment.