playMaker

Author Topic: [Datamaker] Parsing CSV Files with Special Keys instead of Comma [SOLVED]  (Read 5063 times)

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Hi, I am using CSV Reader example (Ecosystem) to parse CSV Strings into variables. When I save the Excel/xlsx with Field Delimiter "," (Comma), there is no problem, this means the Column Cells are seperated with Comma in a CSV file.

But as I plan to use the Strings for Dialogues or long Description texts, I have to rely on using Comma inside the Text Contents instead of using Comma for seperating the content into cells. Therefore I am trying to use "-" symbol to parse/seperate the column cells in this experiment.

So I saved the Excel file with Field Delimiter "-" into CSV (it works fine when opened as CSV, it shows cells are seperated with "-" instead of "," (Comma) and then I added the file in "Read Text Asset" action in CSV Reader Datamaker sample.
However The cells are not parsed at all into variables this time.

I checked the scripts in order to edit, if there is any comma mention to change it into "-", but I couldn't find any. Is it possible to have a custom action that we can add special keys instead of using standard comma in Parsing the CSV file?
Thanks.
« Last Edit: April 11, 2019, 09:15:11 AM by Farwest »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15537
  • Official Playmaker Support
Re: [Datamaker] Parsing CSV Files with Special Keys instead of Comma
« Reply #1 on: March 18, 2019, 02:44:54 AM »
Hi,
 
can you share a file so that I can experiment on this?

Bye,

 Jean

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Re: [Datamaker] Parsing CSV Files with Special Keys instead of Comma
« Reply #2 on: March 20, 2019, 04:44:09 PM »
Hi Jean Fabre,
Sure, please find example CSV files in attachment.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15537
  • Official Playmaker Support
Re: [Datamaker] Parsing CSV Files with Special Keys instead of Comma
« Reply #3 on: March 25, 2019, 04:44:32 AM »
Hi,

 well, "-" is definitly non standard and it doesn't work as good as comma:



I think you should reconsider how you export your data as most csv exporter will take care of the commas inside content and switch to different standard way to setup the delimiter.

anyway, if you want to modify the csv parser to understand - then you need to edit the file csvreader.cs line around line 250 and add a case


Code: [Select]
case '-':
goto case '\n';




this will be in the next version of Data maker and I'll expose this so that you can choose your delimiter before parsing.

Bye,

 Jean



Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Re: [Datamaker] Parsing CSV Files with Special Keys instead of Comma
« Reply #4 on: March 25, 2019, 08:59:12 AM »
This is great, thanks for the update Jean!

Again, the reason why I have to use different special characters is because I can not use comma for setting up the delimiter because there will be dialogues (with commas) used in cells.

A small variable input box with adding special delimiter character in the action will be very nice. I chose using "-", maybe somebody will prefer another special character.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15537
  • Official Playmaker Support
Re: [Datamaker] Parsing CSV Files with Special Keys instead of Comma
« Reply #5 on: March 27, 2019, 03:30:15 AM »
Hi,

 yes, watch for the next update of DataMaker, it will feature that change.

 Bye,

 Jean

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Is it possible if you can say when should we expect the new update?
Or if the action is ready, that would be awesome if you can provide here seperately too. Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15537
  • Official Playmaker Support
Hi,

 can you try this package

it's not an official release, so make sure you back up first or try on a copy of your project.

 the action ReadCsv now accepts a delimiter value, set it to none to ignore or in your case - and it will take that into account.

let me know how it goes.

 Bye,

 Jean

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
I am unsure if I did correct,
I use default CSV Reader Demo scene in this test. After the very first "Read Text Asset" action,  I added Read Csv Action (the action you modified), added same variable from Read Text Asset to Read Csv Action (to both Csv Source and Store Reference), set Delimiter to "-", tried with both Has Header On/Off,
Hit play, the result shows uncut full string from CSV. Unsuccessful.

Please guide me, if there is anything I am missing here, or if the action is working properly, thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15537
  • Official Playmaker Support
Hi,

 did you set with actual quotes or as is, you just need the character itself, not surrounded with quotes.

 Bye,

 Jean

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
No, without quotes of course. I had put quotes for giving emphasizing to the symbol, but you are right to ask, I agree some people do interesting things.

So, without quotes, only: -
And I did as I mentioned on the above. Also for your conveniency, I added .Scene file to attachment for testing. So can you please check?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15537
  • Official Playmaker Support
Hi,

 your unity file doesn't work as is, and the contenbt is odd, your fsm is empty of content.

 I double checked and it works:



Bye,

 Jean

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Hi Jean,
I tested my unity file in a new project and it works. ReadCSV does not process the CSV file properly.

My scene file (.unity) requires a project folder with CSV Reader Example from Ecosystem, and is tested with latest Playmaker. It is using "Read Text Asset" action from the CSV Reader Example (Actually this is its modified test scene).

And scene file uses CSV Reader Example's Test Scene, and has slightly modified states (to check additional functionalities in the previous tests before testing delimiter).

Regardless of the .Unity scene file, I attach screenshots for you, in order to debug the issue visually I hope.

1-This is expected job (I try to get the variables from CSV file into FSM variables in objects. Each row in CSV file spawns as a seperate object. Please see its variables within Playmaker Inspector.). This occurs when I use a default CSV file with "Comma" used as delimiter AND I rely on "Read Text Asset.cs" action only, but "Read CSV action" does not work, as you will see in Picture 3.

2-This is unexpected, failed job. Please notice how the variables look without seperation with delimiter. This happens, because the I used a CSV file with "-" used as delimiter (without quotes).

3-With Read CSV Action. I added your custom Read CSV file to seperate the file with delimiter. Unfortunately this shows how Read CSV Action does not work properly. (I ask again, am I using Read CSV action properly or is the action not working well? Because I am learning Datamaker via this CSV Reader example, I do not put blame on Read CSV action fully.)
Read Text Asset brings the file, Read CSV reads the file from Read Text Asset and saves the data as a second variable (QuestDataRef). And next state "Convert CSV to XML" reads from the second variable (QuestDataRef). If you notice, RecordCount and ColumnCount variables stored correct values, but StoreReference did not store the Data properly. Thus, the next State "Convert CSV to XML" did not properly Convert the CSV to XML, thus it gave "Not Found" event.

4-Without Read CSV Action. This shows how the FSM works properly without Read CSV. As I do not have delimiter support, it gives result of Number-2.

I hope the issue can be solved and I can start making dialogues. Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15537
  • Official Playmaker Support
Re: [Datamaker] Parsing CSV Files with Special Keys instead of Comma
« Reply #13 on: April 11, 2019, 02:28:11 AM »
Hi,

 I see, I did not part the action to conver to xml. It's done now. Please update from the Ecosystem.




Bye,

 Jean

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Re: [Datamaker] Parsing CSV Files with Special Keys instead of Comma
« Reply #14 on: April 11, 2019, 08:56:08 AM »
Now it works very well. Thank you very much!
« Last Edit: April 11, 2019, 09:14:43 AM by Farwest »