This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello! I have strings for my game which contain commas. But Godot import CSV files with only commas as delimiters. How can i import my strings into project?
Thanks!

in Engine by (23 points)

Try to use " signs in your localization files, like "some, text 1", "some, text 2" let me know if it works so I could convert this comment to answer

Yes, thanks! It works!

3 Answers

+2 votes
Best answer

hello,

the way I did it was :
- using MS excel (you can use similar prog)
- making some formulas which would combine my texts between "" for each languages
- select the columns id, language01, language02,...
- copy and paste in notepad
- saved the file in .csv (UTF8)
- finally imported in GODOT.

VoilĂ .

example :
id,fr,en
s112,"112. Le monothéisme pur (Al-Ihlas)","112. Ikhlas, or Purity (of Faith)"
s113,"113. L'aube naissante (Al-Falaq)","113. Falaq, or The Dawn"
s114,"114. Les hommes (An-Nas)","114. Nas, or Mankind"

Hope this helps.

by (169 points)
selected by

Thanks! It works for me

I'm posting this because I think you can make life a lot easier for yourself. I am however writing this with no experience of localisation or using CSV in Godot. My experience with this issue was years ago and in C++, and I was writing my own parser.

If you can specify the delimiter in Godot - which it seems you can, I would suggest Open Office over Excel. Open Office allows you to use any character as the delimiter when exporting to CSV, so you can choose something that doesn't occur anywhere in your text. (If this has changed in more recent versions of Excel, forgive me.) This also spares you the need to enclose the contents in quotes, which massively simplifies parsing. I haven't any experience with CSV in Godot, so I am assuming the quotes aren't required (which may not be the case).

For example, I used the $ character as the delimiter in an application that generated .chm files out of a 16k row spreadsheet. Using commas was problematic, as the contents was all plain text. Handling quotes was an issue, because quotes were also used in the texts and escaping them would have been a massive PITA. Many other special characters ( like pipe (|),hash (#) etc.) were also no-gos as this was technical documentation, so they occured in the content as well. I chose $ for the simple reason that there was not a single occurrence of the character, which massively simplifies parsing. Excel would only let me choose characters that were already in the text as the delimiter :(

You shouldn't need to use formulas should you? Each row and column in your spreadsheet will be separated by your specified delimiters when you export, and you can choose to add quotes around the cell contents when exporting in both Excel and Open Office.

0 votes

How are you importing the CSV files? When I search the API for "csv" I only get this function which allows to specify the delimiter.

by (1,124 points)
+1 vote

Use " char in your localization files, for example: "some, text 1", "some, text 2"

by (1,299 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.