<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Handling two different Excel header formats in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869773#M103273</link>
    <description>&lt;P&gt;Jim's suggestion is great option, other option would be to pull in a bit more data and then do cleanup in JMP&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

path = "$DOWNLOADS/BOM_191910000_Sample_Row5.xlsx";
//path = "$DOWNLOADS/BOM_212100000-A2_Sample_Row6.xlsx";

dt = Open(
	path,
	Worksheets("BOM"),
	Use for all sheets(1),
	Concatenate Worksheets(0),
	Create Concatenation Column(0),
	Worksheet Settings(
		1,
		Has Column Headers(0),
		Data Starts on Row(5),
		Data Starts on Column(1),
		Data Ends on Row(0),
		Data Ends on Column(0),
		Replicated Spanned Rows(1),
		Replicated Spanned Headers(0),
		Suppress Hidden Rows(1),
		Suppress Hidden Columns(1),
		Suppress Empty Columns(1),
		Treat as Hierarchy(0),
		Multiple Series Stack(0),
		Import Cell Colors(0),
		Limit Column Detect(0),
		Column Separator String("-")
	)
);

header_row = Contains(dt[0, 1], "PART NUMBER");
If(header_row &amp;gt; 1,
	dt &amp;lt;&amp;lt; Delete Rows(1::header_row-1);
);
dt &amp;lt;&amp;lt; Move up;

//empty_rows = dt &amp;lt;&amp;lt; Get Rows Where(IsMissing(AsColumn(dt, 1)));
//dt &amp;lt;&amp;lt; delete rows(empty_rows);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 23 Apr 2025 14:45:07 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-04-23T14:45:07Z</dc:date>
    <item>
      <title>Handling two different Excel header formats</title>
      <link>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869745#M103262</link>
      <description>&lt;DIV&gt;Hi everyone,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I'm working on a JSL script in JMP to automate the import of BOM (Bill of Materials) Excel files. These files come from different sources and unfortunately don't follow a consistent format.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I’m dealing with two specific formats:&lt;/DIV&gt;
&lt;DIV&gt;- Format 1: headers are on row 5, data starts on row 6&lt;/DIV&gt;
&lt;DIV&gt;- Format 2: headers are on row 6, data starts on row 7&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Right now, my script is hardcoded to use Format 1 (Headers Start on Row(5)), but I need to manually adjust it whenever I receive files in Format 2.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Goal: I’d like to make the script smart enough to automatically detect the correct format and apply the appropriate import settings (Headers Start on Row, Data Starts on Row), without manual intervention.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Here’s a snippet from the current script:&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= N Items (namefiles), i++,
	//Transformation du fichier en table de données
	dt = Open(
		namefiles[i],
		Worksheets( "BOM" ),
		Use for all sheets( 1 ),
		Concatenate Worksheets( 0 ),
		Create Concatenation Column( 0 ),
		Worksheet Settings(
			1,
			Has Column Headers( 1 ),
			Number of Rows in Headers( 1 ),
			Headers Start on Row( 5 ),
			Data Starts on Row( 6 ),
			Data Starts on Column( 1 ),
			Data Ends on Row( 0 ),
			Data Ends on Column( 0 ),
			Replicated Spanned Rows( 1 ),
			Replicated Spanned Headers( 0 ),
			Suppress Hidden Rows( 1 ),
			Suppress Hidden Columns( 1 ),
			Suppress Empty Columns( 1 ),
			Treat as Hierarchy( 0 ),
			Multiple Series Stack( 0 ),
			Import Cell Colors( 0 ),
			Limit Column Detect( 0 ),
			Column Separator String( "-" )
		)
	);&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;P&gt;Has anyone faced a similar issue? I'm looking for:&lt;/P&gt;
&lt;P&gt;- A way to inspect the first few rows of the Excel file (maybe using a temporary import) to infer where the header actually starts. For example, by checking for known column names.&lt;/P&gt;
&lt;P&gt;- Or any JSL techniques to handle this kind of variability more flexibly.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 23 Apr 2025 13:11:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869745#M103262</guid>
      <dc:creator>Yass</dc:creator>
      <dc:date>2025-04-23T13:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Handling two different Excel header formats</title>
      <link>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869757#M103264</link>
      <description>&lt;P&gt;Could you provide a sample of each of the 2 different formatted files.&amp;nbsp; That would really help to determine the approach to take.&amp;nbsp; Basically what I typically do, is to read in the first 7 rows as a single column.&amp;nbsp; The parse through the table to determine what format it is, and then read in the full table using the determined format.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 13:46:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869757#M103264</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-04-23T13:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Handling two different Excel header formats</title>
      <link>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869762#M103267</link>
      <description>&lt;P&gt;Thanks a lot for your reply.&lt;/P&gt;
&lt;P&gt;I'm attaching the two samples, one for each format.&lt;/P&gt;
&lt;P&gt;I’ll look into how to implement what you suggested to see if I can successfully read the first 7 rows as a single column and Then parse through the table to determine its format and read the full table using the determined format.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I really appreciate your help!&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 14:14:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869762#M103267</guid>
      <dc:creator>Yass</dc:creator>
      <dc:date>2025-04-23T14:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Handling two different Excel header formats</title>
      <link>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869773#M103273</link>
      <description>&lt;P&gt;Jim's suggestion is great option, other option would be to pull in a bit more data and then do cleanup in JMP&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

path = "$DOWNLOADS/BOM_191910000_Sample_Row5.xlsx";
//path = "$DOWNLOADS/BOM_212100000-A2_Sample_Row6.xlsx";

dt = Open(
	path,
	Worksheets("BOM"),
	Use for all sheets(1),
	Concatenate Worksheets(0),
	Create Concatenation Column(0),
	Worksheet Settings(
		1,
		Has Column Headers(0),
		Data Starts on Row(5),
		Data Starts on Column(1),
		Data Ends on Row(0),
		Data Ends on Column(0),
		Replicated Spanned Rows(1),
		Replicated Spanned Headers(0),
		Suppress Hidden Rows(1),
		Suppress Hidden Columns(1),
		Suppress Empty Columns(1),
		Treat as Hierarchy(0),
		Multiple Series Stack(0),
		Import Cell Colors(0),
		Limit Column Detect(0),
		Column Separator String("-")
	)
);

header_row = Contains(dt[0, 1], "PART NUMBER");
If(header_row &amp;gt; 1,
	dt &amp;lt;&amp;lt; Delete Rows(1::header_row-1);
);
dt &amp;lt;&amp;lt; Move up;

//empty_rows = dt &amp;lt;&amp;lt; Get Rows Where(IsMissing(AsColumn(dt, 1)));
//dt &amp;lt;&amp;lt; delete rows(empty_rows);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Apr 2025 14:45:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869773#M103273</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-04-23T14:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Handling two different Excel header formats</title>
      <link>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869774#M103274</link>
      <description>&lt;P&gt;In your spreadsheets, f the name of the first column that is read in using headers of length 6 contains a valid number then the data start row is 6, else it is 6.&lt;/P&gt;
&lt;P&gt;Here is an example that you can start with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
For( i = 1, i &amp;lt;= N Items( namefiles ), i++, 
	//Transformation du fichier en table de données
	dt = Open(
		namefiles[i],
		Worksheets( "BOM" ),
		Use for all sheets( 1 ),
		Concatenate Worksheets( 0 ),
		Create Concatenation Column( 0 ),
		Worksheet Settings(
			1,
			Has Column Headers( 1 ),
			Number of Rows in Headers( 6 ),
			Headers Start on Row( 1 ),
			Data Starts on Row( 7 ),
			Data Starts on Column( 1 ),
			Data Ends on Row( 7 ),
			Data Ends on Column( 0 ),
			Replicated Spanned Rows( 1 ),
			Replicated Spanned Headers( 0 ),
			Suppress Hidden Rows( 1 ),
			Suppress Hidden Columns( 1 ),
			Suppress Empty Columns( 1 ),
			Treat as Hierarchy( 0 ),
			Multiple Series Stack( 0 ),
			Import Cell Colors( 0 ),
			Limit Column Detect( 0 ),
			Column Separator String( "-" )
		)
	);

	If( Is Missing( Num( Word( -1, Column( 1 )[1] ) ) ) == 0,
		whatStartRow = 7;
		whatHeaderStartRow = 6;
	,
		whatStartRow = 6;
		whatHeaderStartRow = 5;
	);
	Close( dt, nosave );

	dt = Open(
		namefiles[i],
		Worksheets( "BOM" ),
		Use for all sheets( 1 ),
		Concatenate Worksheets( 0 ),
		Create Concatenation Column( 0 ),
		Worksheet Settings(
			1,
			Has Column Headers( 1 ),
			Number of Rows in Headers( 1 ),
			Headers Start on Row( whatHeaderStartRow ),
			Data Starts on Row( whatStartRow ),
			Data Starts on Column( 1 ),
			Data Ends on Row( 0 ),
			Data Ends on Column( 0 ),
			Replicated Spanned Rows( 1 ),
			Replicated Spanned Headers( 0 ),
			Suppress Hidden Rows( 1 ),
			Suppress Hidden Columns( 1 ),
			Suppress Empty Columns( 1 ),
			Treat as Hierarchy( 0 ),
			Multiple Series Stack( 0 ),
			Import Cell Colors( 0 ),
			Limit Column Detect( 0 ),
			Column Separator String( "-" )
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Apr 2025 14:49:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Handling-two-different-Excel-header-formats/m-p/869774#M103274</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-04-23T14:49:08Z</dc:date>
    </item>
  </channel>
</rss>

