tab-delimited

Python - Nested List to Tab Delimited File?

假如想象 提交于 2019-12-21 04:26:01
问题 I have a nested list comprising ~30,000 sub-lists, each with three entries, e.g., nested_list = [['x', 'y', 'z'], ['a', 'b', 'c']]. I wish to create a function in order to output this data construct into a tab delimited format, e.g., x y z a b c Any help greatly appreciated! Thanks in advance, Seafoid. 回答1: with open('fname', 'w') as file: file.writelines('\t'.join(i) + '\n' for i in nested_list) 回答2: >>> nested_list = [['x', 'y', 'z'], ['a', 'b', 'c']] >>> for line in nested_list: ... print

File extension for tab-delimited values that can be opened by Excel?

谁都会走 提交于 2019-12-13 04:25:54
问题 I'm outputting a tab-delimited file from my webapp that should be opened in Excel. The problem is that .xls seems not good for opening and editing it, then Excel required some other format, and if I change the extension to .tsv then the file becomes unknown for Excel (on Windows 7) and .csv is for comma-separated. Can you advice me which the file extension should be? This is the code that outputs the file and it works. It's just that I should choose the most suitable extension for tab

tab-delimited string to XML with PHP

六月ゝ 毕业季﹏ 提交于 2019-12-12 04:27:21
问题 I'm trying to write the tab-delimited content of a variable to XML like this: $tsvData = str_getcsv($input, "\t"); foreach($tsvData as $line => $row) { if($line > 0) { $xmlWriter->writeElement('NAME', $row[0]); $xmlWriter->writeElement('CAKE', $row[1]); $xmlWriter->writeElement('BODYPART', $row[2]); } } But it's only writing one character per XML tag instead of everything between each tab. When I use SplFileObject, geting the same tsv data but from a file, it works. What am I doing wrong with

Ruby - Parse a multi-line tab-delimited string into an array of arrays

送分小仙女□ 提交于 2019-12-12 03:53:09
问题 My apologies if this has already been asked in a Ruby setting--I checked before posting but to be perfectly honest it has been a very long day and If I am missing the obvious, I apologize in advance! I have the following string which contains a list of software packages installed on a system and for some reason I am having the hardest time parsing it. I know there has got to be a straight forward means of doing this in Ruby but I keep coming up short. I would like to parse the below multi

reading tab-delimited data without header in pandas

假装没事ソ 提交于 2019-12-10 13:27:08
问题 I'm having trouble using pandas to open tab-delimited data without headers. My test data (actually contains 200 lines, of which I am showing the first 10): Tag19184 CTAAC hffef 1 a 36 - chr1 10006 0 36M 36 Tag19184 CTAAC hffef 1 a 36 - chr1 10012 0 36M 36 Tag19184 CTAAC hffef 1 a 36 - chr1 10018 0 36M 36 Tag19184 CTAAC hffef 1 a 36 - chr1 10024 0 36M 36 Tag19184 CTAAC hffef 1 a 36 - chr1 10030 0 36M 36 Tag19184 CTAAC hffef 1 a 36 - chr1 10036 0 36M 36 Tag19184 CTAAC hffef 1 a 36 - chr1 10042

How to parse tab-delimited data (of different formats) into a data.table/data.frame?

余生长醉 提交于 2019-12-07 08:23:33
问题 I am trying to parse tab-delimited data, which has been saved as a text file with extraneous data. I would like this to be an R data.table/data.frame. The tab-delimited format is the following: A 1092 - 1093 + 1X B 1093 HRDCPMRFYT A 1093 + 1094 - 1X B 1094 BSZSDFJRVF A 1094 + 1095 + 1X B 1095 SSTFCLEPVV ... There are only two types of rows, A and B. A consistently has 5 columns, e.g. for the first row, 1092 - 1093 + 1X B consistently has two columns: 1093 HRDCPMRFYT Question: How do you parse

How to create structured array from Tabdelimited file with PHP?

拜拜、爱过 提交于 2019-12-04 12:21:29
问题 I have a problem with reading a tab delimited file. The structure on my file is: Field 1 Field 2 Field 3 Element11 Element12 Element13 Element21 Element22 Element23 Element31 Element32 Element33 From this file I want to create an array with this structure: $csv = array( array( 'Field 1' => 'Element11', 'Field 2' => 'Element12', 'Field 3' => 'Element13', ), array( 'Field 1' => 'Element21', 'Field 2' => 'Element22', 'Field 3' => 'Element23', ), array( 'Field 1' => 'Element31', 'Field 2' =>

Extract data from tsv file python

心已入冬 提交于 2019-12-04 06:29:00
问题 I have a TSV file, that looks like this: A B C D D=1;E=2 S D F G H=2;B=4 I'd like to write the contents to another tsv file in this way. A B C D D 1 A B C D E 2 S D F G H 2 S D F G B 4 I'd really appreciate if anyone could help/ hint me in splitting column 5 as desired. 回答1: If you are positively sure you only have tabs and semicolons, then you can use split. with open('/tmp/test.tsv') as infile, open('/tmp/test2.tsv', 'w') as outfile: for line in infile: tsplit = line.split("\t")

Extract data from tsv file python

半城伤御伤魂 提交于 2019-12-02 09:25:27
I have a TSV file, that looks like this: A B C D D=1;E=2 S D F G H=2;B=4 I'd like to write the contents to another tsv file in this way. A B C D D 1 A B C D E 2 S D F G H 2 S D F G B 4 I'd really appreciate if anyone could help/ hint me in splitting column 5 as desired. If you are positively sure you only have tabs and semicolons, then you can use split. with open('/tmp/test.tsv') as infile, open('/tmp/test2.tsv', 'w') as outfile: for line in infile: tsplit = line.split("\t") firstcolumns = tsplit[:-1] lastitems = tsplit[-1].strip().split(";") for item in lastitems: allcolumns = firstcolumns +

Opening .dat (tab delimited file) in Excel, save as .xls

谁都会走 提交于 2019-12-01 11:27:07
I am trying to open a .dat file in Excel, which is tab delimited, and then have it save out as a .xls file. So far, I can read in the file and save it as the .xls file but for some reason, all the values are in the first column and it does not tab delimit them. (If I open up the file in Excel without my program, it tab-delimits perfectly) These are the two lines of code that I am using to open and resave the file. xlWorkBook = xlApp.Workbooks.Open(f, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorkBook.SaveAs(filename + "