cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
caseofmondays
Level II

Force column from CSV import as Character not Numeric Date

Hello,

 

My input CSV data files have a Character column in the format of: "##.##.##".

"##" can be anything from 0 to 99.

 

The issue that I am having is that for most of these combinations, when I import the CSV using a basic "Open(filename)" command, the column converts it to a numeric date type which is not useful for me.

 

I have made patch fixes using Month/Day/Year column functions but I was interested in forcing the input to be a Character.

 

A colleague shared the following, which does exactly what I need for local CSV files.

The "Set Date Enable (0)" does exactly what I need.

 

dt = Multiple File Import(
   << Set Folder( csv_file_path ),
   << Set Name Filter( csv_filename ),
   << Set Date Enable( 0 )
) << Import Data;	

My current issue is that I also have CSV files that I download from a URL (not a local file) and I am not sure how to configure the above JSL code to get that to work.

 

URL CSV syntax: "http://xxx.yyy.com:###/api/csv.php?p=#####"

 

Any help is much appreciated.

 

2 REPLIES 2
Phil_Kay
Staff

Re: Force column from CSV import as Character not Numeric Date

Hi,

 

I think this discussion will be helpful for you to understand more about the syntax for Multiple File Import(): How can I prevent 3-digit version numbers from getting read as dates into data table? 

 

I think that you will find that it is not the Set Date Enable argument that is enabling the correct import of your character data column. Rather, it is because the Import Multiple Files platform inherently will not try to guess date formats. Set Date Enable is determining whether or not the date filter is turned on (so that you could filter on a date range).

 

See here for more on the arguments: https://www.jmp.com/support/help/en/15.1/#page/jmp/utility-functions.shtml#ww7168938

 

That does not really answer your question but I hope it helps.

 

Regarding your question: are you using JSL because this is an action that you need to repeat or could you just use the point-and-click interface in JMP? I would think it would be worth experimenting with using the point-and-click interface to Import Multiple Files to get a better understanding of your problem.

 

Phil 

nikles
Level VI

Re: Force column from CSV import as Character not Numeric Date

Hi.  I agree 100%.  I just posted a slightly more generalized version of your request that applies for Open(), Multiple File Import(), and both csv and xlsx files.  Linking here for visibility: Force Character Column Data Type for Open() and Multiple File Import()