Help

Mapping Fields with Scripting Block

Topic Labels: Scripting extentions
1401 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Sam_Cederwall
7 - App Architect
7 - App Architect

Hello, I have been working towards mapping some CSVs into one of my bases using the Scripting Block. Since I’m new to JavaScript, I’ve been using a lot of the documentation within the Scripting Block, which has been super helpful for what I need.

One issue I have run into is during the mapping process, where I’m mapping the fields in my Base to the fields within my CSV.

The format of mapping a field for me generally looks like this:

data.FieldName

Where “data” represents the parsed contents of my file and “FieldName” represents the name of the field within that file. My issue is that, in some of the files I would like to use, there are special characters and spaces within the names of the fields. Meaning I would like have a mapping that might look something like this:

data.Field Name #

For spaces, I attempted to use underscores but wasn’t able to get that to work. When using a special character like # or /, I get errors thrown by the script.

From my understanding, I believe this mapping process uses something called identifiers which exclude certain characters (such as #s, /s, and spaces). My question is whether or not there is a way to include those spaces and special characters that will work with my script? My other option would be changing the fields w/i the CSV, but ideally, I would like my script to handle this issue.

Any help is greatly appreciated. Thank you.

2 Replies 2
Orvin_Hilomen
4 - Data Explorer
4 - Data Explorer

How come you’re not using the CSV import block? If it’s because the Scripting block is included in the free plan for now, the JS associative array support for names with spaces is data[“Field Name #”].

Hello, thanks for the reply. I should have clarified the reason I’m not using the CSV block is because I would like to do some pre-processing to my data. We have a few different sources of data, and my base will capture those sources coming together, because of this, I need to be able to add certain fields from certain CSVs prior to letting them into my base.

Thank you for the advice. This seems to have done the trick!