cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
ealindahl
Level II

Importing txt column missing

I am importing a txt file that has junk in the first row and data starts on the second. The junk data is not consistent between different files so I want to get rid of it, but when I use the following to get rid of the first line and designate no headers, the first column of data disappears. How do I import this file without losing that column and without column headers.

Alternatively can I import the file with the column headers and then rename each column based on its position rather than based on its title?

open(File,

Table Contains Column Headers (0),
Treat Empty Columns as Numeric(1)
Data Starts|Data starts on line (2)

);

 

0	2022-06-23 14:55:29	#ARC-FILE#	1.1a	2022-05-04	2022-06-23	CEDEX BIO HT	630026	6.0.1.2102 (1905)	ADMIN																
10	2022-06-14 10:20:59	CA2B	CAL C	62232400	261	62809100	mg/L	 	  78.00	  0.00					  0.10250	  0.00779					  0.0077860	  20.546763	 	 	 
10	2022-06-14 10:22:18	CA2D	CAL C	62232400	261	62809100	mg/L	 	  780.00	  0.00					  0.10121	  0.00793					  0.0079316	  20.863648	 	 	 
10	2022-06-14 10:23:01	FE2B	CAL C	62232400	572	61840600	mg/L	 	  3.80	  0.00					  0.04336	  0.00318					  0.0031815	  1693.9365	 	 	 

ealindahl_0-1656434604652.png

 

 

1 REPLY 1
jthi
Super User

Re: Importing txt column missing

I would suggest opening the file with Open menu and using Preview:

jthi_0-1656439998471.png

then it is easier to see what different options do

jthi_1-1656440017535.png

jthi_2-1656440024804.png

jthi_3-1656440037699.png

and you can get the script from table script.

View more...
Open(
	"$DOWNLOADS/junk.txt",
	columns(
		New Column("c000001", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000002",
			Numeric,
			"Continuous",
			Format("y/m/d h:m:s", 22, 0),
			Input Format("y/m/d h:m:s", 0)
		),
		New Column("c000003", Character, "Nominal"),
		New Column("c000004", Character, "Nominal"),
		New Column("c000005", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000006", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000007", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000008", Character, "Nominal"),
		New Column("c000009", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000010", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000011", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000012", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000013", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000014", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000015", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000016", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000017", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000018", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000019", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000020", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000021", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000022", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000023", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000024", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000025", Numeric, "Continuous", Format("Best", 12)),
		New Column("c000026", Numeric, "Continuous", Format("Best", 12))
	),
	Import Settings(
		End Of Line(CRLF, CR, LF),
		End Of Field(Tab, CSV(0)),
		Strip Quotes(1),
		Use Apostrophe as Quotation Mark(0),
		Use Regional Settings(0),
		Scan Whole File(1),
		Treat empty columns as numeric(0),
		CompressNumericColumns(0),
		CompressCharacterColumns(0),
		CompressAllowListCheck(0),
		Labels(0),
		Column Names Start(1),
		Data Starts(2),
		Lines To Read("All"),
		Year Rule("20xx")
	)
)

 

 

-Jarmo