1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

Windows [SOLVED] Problem with importing .csv files

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Rob, Feb 13, 2020.

Tags:
  1. Rob

    Rob Member

    Joined:
    Jul 12, 2016
    Posts:
    769
    Ever since I've been importing .csv files using the load_csv function, I've had a particular problem and I don't understand what's causing it.

    When I try to read the data from cell 0, 0 there is always some kind of issue. If it's a number, gamemaker gives me an error saying that it cannot convert the number into a real.

    If it's a string, the string that gamemaker puts out is slightly different than what's in the .csv (from memory it was some kind of rectangular character?)

    I know I can use string_digits (which was the fix I used for converting the string into a number) but I just wondered if I was missing something.
     
  2. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,001
    How is the text file encoded? If it's only cell 0,0, I'm suspecting that's a byte order mark messing up your import. Make sure it's encoded as UTF-8 (without BOM).
     
  3. Rob

    Rob Member

    Joined:
    Jul 12, 2016
    Posts:
    769
    At the moment I make an excel sheet, fill it out, and then File > Save As > and then choose this highlighted option "CSV UTF-8 (Comma delimited) (*.csv)". I couldn't find out what BOM was, sorry :(

    Screenshot 2020-02-13 20.06.10.png
     
  4. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,001
    BOM means byte order mark. It's a series of characters at the start of a file to indicate some aspects about its encoding - in the case of UTF-8, that's "" (which may be drawn as squares if your font does not support these characters). The fact that your issue only happens with the top-leftmost cell, so the one at the start of the file, leads me to suspect that the file may have a BOM that is being read as a part of that cell, leading to the problem you described.

    Open the generated file in Notepad++. Under Encoding, make sure that the "Encode in UTF-8" (as opposed to UTF-8 BOM) option is checked. If not, convert it to UTF-8.
     
    gnysek and Rob like this.
  5. gnysek

    gnysek Member

    Joined:
    Jun 20, 2016
    Posts:
    1,390
    I think that in latest Windows 10 builds (1903+) even normal Notepad allows to save in UTF-8 without BOM (by default!).
     

Share This Page