delimiter-separated-values

Parsing a pipe delimited file in python

天涯浪子 提交于 2019-12-17 18:12:53
问题 I'm trying to parse a pipe delimited file and pass the values into a list, so that later I can print selective values from the list. The file looks like: name|age|address|phone|||||||||||..etc It has more than 100 columns. 回答1: If you're parsing a very simple file that won't contain any | characters in the actual field values, you can use split: fileHandle = open('file', 'r') for line in fileHandle: fields = line.split('|') print(fields[0]) # prints the first fields value print(fields[1]) #

How to read file with space separated values in pandas

不问归期 提交于 2019-12-17 08:57:26
问题 I try to read the file into pandas. The file has values separated by space, but with different number of spaces I tried: pd.read_csv('file.csv', delimiter=' ') but it doesn't work 回答1: add delim_whitespace=True argument, it's faster than regex. 回答2: you can use regex as the delimiter: pd.read_csv("whitespace.csv", header=None, delimiter=r"\s+") 来源: https://stackoverflow.com/questions/19632075/how-to-read-file-with-space-separated-values-in-pandas

How to read file with space separated values in pandas

a 夏天 提交于 2019-12-17 08:57:09
问题 I try to read the file into pandas. The file has values separated by space, but with different number of spaces I tried: pd.read_csv('file.csv', delimiter=' ') but it doesn't work 回答1: add delim_whitespace=True argument, it's faster than regex. 回答2: you can use regex as the delimiter: pd.read_csv("whitespace.csv", header=None, delimiter=r"\s+") 来源: https://stackoverflow.com/questions/19632075/how-to-read-file-with-space-separated-values-in-pandas

Delimit array with different strings

雨燕双飞 提交于 2019-12-11 17:29:39
问题 I have a text file that contains 3 columns of useful data that I would like to be able to extract in python using numpy. The file type is a *.nc and is NOT a netCDF4 filetype. It is a standard file output type for CNC machines. In my case it is sort of a CMM (coordinate measurement machine). The format goes something like this: X0.8523542Y0.0000000Z0.5312869 The X,Y, and Z are the coordinate axes on the machine. My question is, can I delimit an array with multiple delimiters? In this case: "X

Parsing a pipe delimited file in python

老子叫甜甜 提交于 2019-11-28 06:39:24
I'm trying to parse a pipe delimited file and pass the values into a list, so that later I can print selective values from the list. The file looks like: name|age|address|phone|||||||||||..etc It has more than 100 columns. If you're parsing a very simple file that won't contain any | characters in the actual field values, you can use split : fileHandle = open('file', 'r') for line in fileHandle: fields = line.split('|') print(fields[0]) # prints the first fields value print(fields[1]) # prints the second fields value fileHandle.close() EDIT: A more robust way to parse tabular data would be to

How to read file with space separated values in pandas

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 07:11:16
I try to read the file into pandas. The file has values separated by space, but with different number of spaces I tried: pd.read_csv('file.csv', delimiter=' ') but it doesn't work add delim_whitespace=True argument, it's faster than regex. you can use regex as the delimiter: pd.read_csv("whitespace.csv", header=None, delimiter=r"\s+") 来源: https://stackoverflow.com/questions/19632075/how-to-read-file-with-space-separated-values-in-pandas

MySQL: Split comma separated list into multiple rows

杀马特。学长 韩版系。学妹 提交于 2019-11-26 05:59:20
问题 I have an unnormalized table with a column containing a comma separated list that is a foreign key to another table: +----------+-------------+ +--------------+-------+ | part_id | material | | material_id | name | +----------+-------------+ +--------------+-------+ | 339 | 1.2mm;1.6mm | | 1 | 1.2mm | | 970 | 1.6mm | | 2 | 1.6mm | +----------+-------------+ +--------------+-------+ I want to read this data into a search engine that offers no procedural language. So is there a way to either

SQL split values to multiple rows

送分小仙女□ 提交于 2019-11-25 22:16:51
问题 I have table : id | name 1 | a,b,c 2 | b i want output like this : id | name 1 | a 1 | b 1 | c 2 | b 回答1: If you can create a numbers table, that contains numbers from 1 to the maximum fields to split, you could use a solution like this: select tablename.id, SUBSTRING_INDEX(SUBSTRING_INDEX(tablename.name, ',', numbers.n), ',', -1) name from numbers inner join tablename on CHAR_LENGTH(tablename.name) -CHAR_LENGTH(REPLACE(tablename.name, ',', ''))>=numbers.n-1 order by id, n Please see fiddle