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
mariochoi
Level I

How to make the first row as the header???

Dear all,

 

I got in trouble while creating C# JMP automation program,

 

Once opening up a CSV file, I'm not able to find a command to make the first row as the header.

here is my code so far, please give me any idea or help... 

 

JMP.Document doc, doc2;
JMP.TextImport ti;
JMP.DataTable jmpDT, jmpRT;

startJMP();

doc = myJMP.OpenDocument(jmpInstallDir + "Samples\\Data\\1111.CSV");
jmpDT = doc.GetDataTable();


myJMP.Visible = true;


jmpDT.SelectRows(0, 49);
jmpDT.SelectRows(51, 53);
jmpDT.DeleteSelectedRows();
jmpDT.SelectRows(1, 1);

 

1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: How to make the first row as the header???

I suggest you read the JMP Automation Reference and look up Text Import. Below is an excerpt and a portion of a VB automation example for Text Import. 

 

I find JSL easier to use, so you might want to look up how to run JSL within your C script. 

 

ColumnNamesStart(StartLine as Integer)
Specifies the starting line for column headers. This implies that the file has column headers, so a
positive value here obviates the need for a call to FirstLineIsData(False). The line that contains
column names must come before the first line of data.

 

DataStarts(StartLine As Integer)
Specifies the starting line for the row data. If the number specified is 1, than it is implied that there
are no column headers. A call to FirstLineIsData(True) is not necessary in this particular case.

 

FirstLineIsData(Flag As Boolean)
Indicates if the first line of the text file should be interpreted as data or as column headers. True
means data, False means header.

 

OpenFile() As Document
Opens the text file, using the options specified in the preceding methods. A Document object
pointer is returned. To retrieve a object pointer to the underlying data table, use the GetDataTable
method on the document object.

Private Sub TestEOF_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TestEOF.Click
        TI1 = MyJMP.CreateTextImportObject(InstallDir & "\Samples\Import Data\EOF_space.TXT", 5)
		' Set columns 1 and 3 as having type "Character"
		' The default is "Numeric"
        TI1.SetColumnType(1, JMP.colDataTypeConstants.dtTypeCharacter)
        TI1.SetColumnType(3, JMP.colDataTypeConstants.dtTypeCharacter)
		'Set space as the only end-of-field option
        TI1.SetEndOfFieldOptions(JMP.jmpTIEndOfFieldConstants.tiSpace)
		'Set carriage return line feed as the end-of-line delimeter
        TI1.SetEndOfLineOptions(JMP.jmpTIEndOfLineConstants.tiCRLF)
        TI1.FirstLineIsData(True)
		'Open the file
        Doc1 = TI1.OpenFile
		'Name the document window
        Doc1.Name = "SPACE"
		'Now open two more files.  TI2 gets a file with spaces as
		'end-of-field delimeters, TI3 gets one with commas.
        TI2 = MyJMP.CreateTextImportObject(InstallDir & "\Samples\Import Data\EOF_spaces.TXT", 5)
        TI2.SetColumnType(1, JMP.colDataTypeConstants.dtTypeCharacter)
        TI2.SetColumnType(3, JMP.colDataTypeConstants.dtTypeCharacter)
        TI2.SetEndOfFieldOptions(JMP.jmpTIEndOfFieldConstants.tiSpaces)
        TI2.SetEndOfLineOptions(JMP.jmpTIEndOfLineConstants.tiCRLF)
        TI2.FirstLineIsData(True)
        Doc2 = TI2.OpenFile
        Doc2.Name = "SPACES"
        TI3 = MyJMP.CreateTextImportObject(InstallDir & "\Samples\Import Data\EOF_comma.TXT", 5)
		TI3.SetColumnType(1, JMP.colDataTypeConstants.dtTypeCharacter)
		TI3.SetColumnType(3, JMP.colDataTypeConstants.dtTypeCharacter)
		TI3.SetEndOfFieldOptions((JMP.jmpTIEndOfFieldConstants.tiComma))
		TI3.SetEndOfLineOptions((JMP.jmpTIEndOfLineConstants.tiCRLF))
		TI3.FirstLineIsData((True))
		Doc3 = TI3.OpenFile
		Doc3.Name = "COMMA"
    End Sub

View solution in original post

2 REPLIES 2
gzmorgan0
Super User (Alumni)

Re: How to make the first row as the header???

I suggest you read the JMP Automation Reference and look up Text Import. Below is an excerpt and a portion of a VB automation example for Text Import. 

 

I find JSL easier to use, so you might want to look up how to run JSL within your C script. 

 

ColumnNamesStart(StartLine as Integer)
Specifies the starting line for column headers. This implies that the file has column headers, so a
positive value here obviates the need for a call to FirstLineIsData(False). The line that contains
column names must come before the first line of data.

 

DataStarts(StartLine As Integer)
Specifies the starting line for the row data. If the number specified is 1, than it is implied that there
are no column headers. A call to FirstLineIsData(True) is not necessary in this particular case.

 

FirstLineIsData(Flag As Boolean)
Indicates if the first line of the text file should be interpreted as data or as column headers. True
means data, False means header.

 

OpenFile() As Document
Opens the text file, using the options specified in the preceding methods. A Document object
pointer is returned. To retrieve a object pointer to the underlying data table, use the GetDataTable
method on the document object.

Private Sub TestEOF_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TestEOF.Click
        TI1 = MyJMP.CreateTextImportObject(InstallDir & "\Samples\Import Data\EOF_space.TXT", 5)
		' Set columns 1 and 3 as having type "Character"
		' The default is "Numeric"
        TI1.SetColumnType(1, JMP.colDataTypeConstants.dtTypeCharacter)
        TI1.SetColumnType(3, JMP.colDataTypeConstants.dtTypeCharacter)
		'Set space as the only end-of-field option
        TI1.SetEndOfFieldOptions(JMP.jmpTIEndOfFieldConstants.tiSpace)
		'Set carriage return line feed as the end-of-line delimeter
        TI1.SetEndOfLineOptions(JMP.jmpTIEndOfLineConstants.tiCRLF)
        TI1.FirstLineIsData(True)
		'Open the file
        Doc1 = TI1.OpenFile
		'Name the document window
        Doc1.Name = "SPACE"
		'Now open two more files.  TI2 gets a file with spaces as
		'end-of-field delimeters, TI3 gets one with commas.
        TI2 = MyJMP.CreateTextImportObject(InstallDir & "\Samples\Import Data\EOF_spaces.TXT", 5)
        TI2.SetColumnType(1, JMP.colDataTypeConstants.dtTypeCharacter)
        TI2.SetColumnType(3, JMP.colDataTypeConstants.dtTypeCharacter)
        TI2.SetEndOfFieldOptions(JMP.jmpTIEndOfFieldConstants.tiSpaces)
        TI2.SetEndOfLineOptions(JMP.jmpTIEndOfLineConstants.tiCRLF)
        TI2.FirstLineIsData(True)
        Doc2 = TI2.OpenFile
        Doc2.Name = "SPACES"
        TI3 = MyJMP.CreateTextImportObject(InstallDir & "\Samples\Import Data\EOF_comma.TXT", 5)
		TI3.SetColumnType(1, JMP.colDataTypeConstants.dtTypeCharacter)
		TI3.SetColumnType(3, JMP.colDataTypeConstants.dtTypeCharacter)
		TI3.SetEndOfFieldOptions((JMP.jmpTIEndOfFieldConstants.tiComma))
		TI3.SetEndOfLineOptions((JMP.jmpTIEndOfLineConstants.tiCRLF))
		TI3.FirstLineIsData((True))
		Doc3 = TI3.OpenFile
		Doc3.Name = "COMMA"
    End Sub
mariochoi
Level I

Re: How to make the first row as the header???

Hi gzmorgan,

 

awesome!!! it works,

 

Thanks for the great advice :)

 

Mario.Choi