+1 vote


Problem 1:
Clicking and dragging a .csv file into the project file panel causes this error: ' Error importing CSV translation: 'statecode' is not a valid locale'. It also causes Godot to show the file as a red icon in the folders panel.

I have tried several .csv files and get the same problem.

Problem 2:
Changing the file postfix to .txt causes Godot not to recognise the file as it does not appear in Godot's folders panel. The following script prints "could not open file":

if file.open(filename, file.READ) != 0:
        print("opened file")
        #get_csv_line ( String delim=”,” ) 
        while not file.eof_reached():
            var line = file.get_line()
            result[str(index)] = line
            index += 1
        print("Could not open file")

What am I doing wrong?


in Engine by (92 points)

If you're using 3.0+ of the engine, you may be able to still use the files even if they don't show up in the editor. I think the editor only looks for files related to Godot, e.g. tscn, jpg, png, and json. I've been able to do this, yet the method to do that currently escapes me.

I'm using 3.2.beta4

If your CSV file does not contain translation info, you need to re-import the resource as "CSV" (default = "CSV Translation") ! The red cross will be replaced by another icon.

2 Answers

+2 votes
Best answer

You did not specify the value for filename. Either you omitted in your post or that is the problem.

I use a csv file in the project. And although there's a red cross, this file is readable.

You could however put the file in an own directory (i.e. res://data) and add a .gdignore file to that.
...but this would mean that the file will not be shown in the godot file manager and I doubt that it'll be included if you export the project. So I'd vote against using .gdignore.

Here's a part of a working code example:

var groupname=""
var file = File.new()
file.open("res://resources/data/llangollen_aqueduct_trees.csv", file.READ)
while !file.eof_reached():
    var csv = file.get_csv_line ()
        if csv.size()>=7:
                if csv[2] != groupname:
by (3,358 points)
selected by

Thanks wombatstampede. Appreciate your time on this.

0 votes
by (51 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.