godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Additional option for Importing CSV File as Text File #7321

Open tokengamedev opened 1 year ago

tokengamedev commented 1 year ago

Describe the project you are working on

Projects where I use CSV as data file and not as translation file.

Describe the problem or limitation you are having in your project

Currently if you import CSV file in Godot 4.1.1, It can only import as CSV translation file. It is all fine. The issue arises when we want to use the file for data purposes.

It automatically adds a translation file named <original_file_name_without_extension>.<content of 1st row 2nd column>.translation This is not required, and also cannot be deleted. It is overhead.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The feature is just to bypass the translation import in case required. Currently either you import as CSV Translation or not.

It is understood that data management is not part of the engine or the editor, but reading a file as text file helps quick edits, which is being already done for text files. Instead of ignoring it completely, read it as text file.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

My proposal to add an option Text File to Import As in Import tab.

This will handle the cases where CSV file is not required as Translation files but as text data

If this enhancement will not be used often, can it be worked around with a few lines of script?

Currently the engine behaves erratically with files, if it is not of the CSV translation format.

Also it cannot ignore it like other Text file formats as it is also one of the most used text file formats and the extension is being used for importing.

The basic things to ask is, not to generate the translation file.

Is there a reason why this should be core and not an add-on in the asset library?

It is enhancement to the core functionality.

KoBeWi commented 1 year ago

image

tokengamedev commented 1 year ago

@KoBeWi , that is not the correct option IMO. I have done that, this excludes the file from the project and unable to read(by the editor) the file altogether, although, the file is visible in file explorer. This option is reserved for excluding files from project, it is applicable for all file types.

My point of the proposal is for graceful exit case for CSV file.

There are other workarounds too, like changing the extension itself to txt and read it in the code.

KoBeWi commented 1 year ago

You can open the file in script editor using the File -> Open option. There is docks/filesystem/textfile_extensions editor setting, but adding csv does not make the file editable from filesystem. I'd even say it's a bug.

tokengamedev commented 1 year ago

I did not know that configuration. but surely it is a hidden gem 💎 to be able to add another text file extensions. I will try this sometime, but in this case of CSV, it has to be handled.

golddotasksquestions commented 1 year ago

@KoBeWi Yes, you can still read the file and work with it, but it's like Godot is trying to make it as obscure and opaque for the user as possible.

"No import" as a setting sounds like the file is not available at all, and even if the user realized they can still use the csv file, they then are further confused by the CSV not showing up in the exported, unless they also learned about and remembered about the export file filter settings.

It's terrible!

CSV files are extremely common for writers and game designers to be used for balancing and dialog in slightly larger teams where the game designer or writer is not also a programmer or engine expert.

@tokengamedev You might want to add this issue to your post as related link since this discussion already goes on for years: https://github.com/godotengine/godot/issues/19627

tokengamedev commented 1 year ago

@golddotasksquestions , I don't know how to link it, but thanks for informing about an existing issue and the discussions.

I will add my two cents, from my decades of experience.

Primarily, I see the issue here is using a standard file format and using it for a specific work under Godot, and when people want to use standard file format as it was intended to be used, then it becomes an issue.

I think it is the responsibility of the reviewer to guard against such type of issues.

The primary solution should have been not to use csv extension itself for the translation files rather used like e.g., "tgdt" (Text, like CSV) and after parsing should have been "gdt" (Binary).

I peeped into the code, and had urge of writing the code myself, but I will leave it to the maintainer for now.

Calinou commented 1 year ago

Primarily, I see the issue here is using a standard file format and using it for a specific work under Godot, and when people want to use standard file format as it was intended to be used, then it becomes an issue.

I think it is the responsibility of the reviewer to guard against such type of issues.

For the record, CSV in Godot has always worked this way, even the very first day Godot was open sourced (which means it also worked like this when Godot was a in-house engine). This means there was no reviewer to speak of (on GitHub) :slightly_smiling_face:

Using a custom file extension unfortunately makes the localization process more cumbersome, as most spreadsheet tools will not allow saving a file with a custom extension as CSV (with Ctrl + S at least). This can be a significant workflow hindrance that adds up over time.

Zireael07 commented 1 year ago

Yeah, I agree that a custom extension is NOT the way to go.

tokengamedev commented 1 year ago

Using a custom file extension unfortunately makes the localization process more cumbersome, as most spreadsheet tools will not allow saving a file with a custom extension as CSV (with Ctrl + S at least). This can be a significant workflow hindrance that adds up over time.

I kind of mildly disagree, as this is not that complicated that a python script cannot handle.

I am not worried about the extensions for translation, rather worried about .csv files to be used for translation only. It kind of understood that .csv file will not be used for anything else other than translation.

golddotasksquestions commented 1 year ago

Imho this all could easily be solved by simply not defaulting to csv being imported as translation files. They should still be able to be imported as translation. Maybe with a simple checkmark.

Only because something like this has been done so for ages does not mean we should never change it. Back when Godot was first open sourced, it did not remotely have as many users as it has now. Bigger teams want to use Godot now. With bigger teams come dedicated jobs, for example game designers who are experienced spread sheet users, but not experienced engine users. I have worked with many such game designers and writers in my career. They use spreadsheets all the time to control various game aspects.

Times have changed for Godot. CSV is not only useful as translation any more as it were when only Juan, Ariel, their clients and a few earily adopters where using Godot. We need to move away from csv being imported as translation by the default import, because it has way more usecases in game development than this one specific usecase. While still allowing it to be easily used for translation.

gmikhail commented 7 hours ago

I would also like to be able to open the CSV file in Script Editor by double click from FileSystem as a regular text file. Right now (in Godot v4.3.stable) when I try to open a CSV file I get an error:

Resource file not found:  (expected type: Translation)
  Failed loading resource: res://translations.csv. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1278 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN

2024-09-12 173151

And you have to open the CSV file in Script Editor manually via File > Open... > All Files (*):

2024-09-12 175638

In the long term, it is assumed that the CSV file will be opened in a Spreadsheet Editor: https://github.com/godotengine/godot-proposals/issues/13

But in the short term, it is better to give the ability to open the CSV file as plain text, because it often happens that you need to quickly edit the data in CSV, but it is impossible to do this in Godot quickly, and you will have to use a third-party text editor, which takes additional time.

TLDR: I am requesting the ability to edit CSV files as regular TXT files.