delimiter

How to skip extra lines before the header of a tab delimited delimited file in R

[亡魂溺海] 提交于 2019-12-06 06:58:05
问题 The software I am using produces log files with a variable number of lines of summary information followed by lots of tab delimited data. I am trying to write a function that will read the data from these log files into a data frame ignoring the summary information. The summary information never contains a tab, so the following function works: read.parameters <- function(file.name, ...){ lines <- scan(file.name, what="character", sep="\n") first.line <- min(grep("\\t", lines)) return(read

Multiple delimiters in column headers also separates the row values

亡梦爱人 提交于 2019-12-06 05:41:05
I had a some issue about defining multiple seperator when reading a file. It is originally solved in my previous post reading-files-with-multiple-delimiter-in-column-headers-and-skipping-some-rows thanks to @piRsquared When I looked in detail to my real data I realized that some columns have .cd or .dvd extensions and when I applied the solution above they are also separated as a new column and the solution above started not to work! b.txt skip1 A1| A2 |A3 |A4# A5# A6 A7| A8 , A9 1,2,3,4,5.cd,6,7,8.dvd,9 1,2,3,4,5.cd,6,7,8.dvd,9 1,2,3,4,5.cd,6,7,8.dvd,9 END123 Some other data starts from here

Using MySQL LOAD DATA INFILE with nonprintable character delimiters

本小妞迷上赌 提交于 2019-12-06 05:09:46
I have some vendor data that has the SOH (ASCII character 1) as the field delimiter and STX (ASCII character 2) as the record delimiter. Is it possible to load this data with LOAD DATA INFILE without pre-processing the file and replacing those characters with something more common? I got it. LOAD DATA LOCAL INFILE 'myfile.txt' INTO TABLE my_table CHARACTER SET UTF8 FIELDS TERMINATED BY X'01' LINES TERMINATED BY X'02' (col1, col2, col3); You might try FIELDS TERMINATED BY _ascii 0x02 . I don't know if it will work for LOAD DATA INFILE , but it works in SELECT (i.e., SELECT _ascii 0x61 yields 'a

Split list into lists based on a character occurring inside of an element

…衆ロ難τιáo~ 提交于 2019-12-06 04:25:59
问题 In a list like the one below: biglist = ['X', '1498393178', '1|Y', '15496686585007', '-82', '-80', '-80', '3', '3', '2', '|Y', '145292534176372', '-87', '-85', '-85', '3', '3', '2', '|Y', '11098646289856', '-91', '-88', '-89', '3', '3', '2', '|Y', '35521515162112', '-82', '-74', '-79', '3', '3', '2', '|Z', '0.0', '0.0', '0', '0', '0', '0', '0', '4', '0', '154'] There could be some numerical elements preceded by a character. I would like to break this into sub-lists like below: smallerlist = [

How to create mysql event inside a procedure or trigger?

瘦欲@ 提交于 2019-12-06 04:25:44
问题 recently i've been searching for a solution to the following situation: I have mysql table with structure: CREATE TABLE IF NOT EXISTS `battles` ( `id` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(1) NOT NULL, `created` datetime NOT NULL, `modified` datetime NOT NULL, `begindate` datetime NOT NULL, `enddate` datetime NOT NULL, PRIMARY KEY (`id`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; Every battle has begindate and enddate. Begindate is datetime of

Transform comma separated string into a list but ignore comma in quotes

◇◆丶佛笑我妖孽 提交于 2019-12-06 03:53:46
问题 How do I convert "1,,2'3,4'" into a list? Commas separate the individual items, unless they are within quotes. In that case, the comma is to be included in the item. This is the desired result: ['1', '', '2', '3,4'] . One regex I found on another thread to ignore the quotes is as follows: re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''') But this gives me this output: ['', '1', ',,', "2'3,4'", ''] I can't understand, where these extra empty strings are coming from, and why the two commas are

bash string to array with spaces and extra delimiters

纵然是瞬间 提交于 2019-12-06 03:09:47
问题 I'm trying to create arrays from strings that have pipe ("|") as delimiters and include spaces. I've been looking around for a while and I've gotten close thanks to sources like How do I split a string on a delimiter in Bash?, Splitting string into array and a bunch more. I'm close but it's not quite working. The two main problems are that there are spaces in the strings, there are starting and ending delimiters, and some of the fields are blank. Also, instead of just echoing the values, I

Parser in python3 does not take delimiter values from commandline via argparse

萝らか妹 提交于 2019-12-06 03:04:07
I have written a simple script as an advanced tool for my awk / sed requirements. In the script I compare two files on basis of values from one column of the query file and then extract whole entries from the master file. The script allows you to enter the values for columns and delimiters for each file. The problem is that the 'delimiter' options are not recognized by script when given from command line. Here is my code (partial): ##- - - - - - - -- - - - - - Arguments - - - - - - - - - - - - - -## parser = argparse.ArgumentParser() ## Command line options parser.add_argument("-m", "--master"

Change lines that match a pattern in between delimiters using awk

别来无恙 提交于 2019-12-06 02:07:22
I have an input file something like this: some line some other line another line start_delimiter interesting stuff more interesting stuff even more interesting stuff end_delimiter possibly more stuff I want to manipulate the lines between start_delimiter and end_delimiter that match a regex pattern and write the results to the input file. For example, add '//' to the beginning of the lines containing the word 'more' (as long as those lines are between the delimiters): some line some other line another line start_delimiter interesting stuff //more interesting stuff //even more interesting stuff

PHP - Best approach to detect CSV delimiter

女生的网名这么多〃 提交于 2019-12-06 00:39:01
问题 I have seen multiple threads about what the best solution to auto detect the delimiter for an incoming CSV. Most of them are functions of length between 20 - 30 lines, multiple loops pre-determined list of delimiters, reading the first 5 lines and matching counts e.t.c e.t.c Here is 1 example I have just implemented this procedure, with a few modifications. Works brilliantly. THEN I found the following code: private function DetectDelimiter($fh) { $data_1 = null; $data_2 = null; $delimiter =