delimiter

How to use delimiter for csv in python

末鹿安然 提交于 2019-12-04 16:32:35
问题 I'm having trouble with figuring out how to use the delimiter for csv.writer in Python. I have a csv file in which the strings separated by commas are in single cell and I need to have each word in each individual cell. For ex: 100 , 2559 ,,Main, St,LEOMA,LEOMA,498,498, AK,AK 140 , 425 ,,Main, St,LEOMA,LEOMA,498,498, AK,AK 100 , 599 ,,Main, St,LEOMA,LEOMA,498,498, AK,AK should be 100 2559 Main St LEOMA LEOMA 498 498 AK AK 140 425 Main St LEOMA LEOMA 498 498 AK AK 100 599 Main St LEOMA LEOMA

bash: passing paths with spaces as parameters?

ぐ巨炮叔叔 提交于 2019-12-04 16:20:22
问题 I have a bash script that recieves a set of files from the user. These files are sometimes under directories with spaces in their names. Unfortunately unlike this question all the filenames are passed via the command line interface. Let's assume the paths are correctly quoted as they are passed in by the user, so spaces (save for quoted spaces) are delimiters between paths. How would I forward these parameters to a subroutine within my bash script in a way that preserves the quoted spaces?

How to do a while loop with a string redirected into it

有些话、适合烂在心里 提交于 2019-12-04 14:32:23
问题 Im trying to loop though a string with HTTP links inside and newlines, I want to loop over a line at a time. At the moment I have echo -e "$HTTP_LINKS" | while read HTTP_S_LINK ; do TEST_STRING="test" done But this way I don't have access to the TEST_STRING out side the loop, which is what I want. I'm using the while loop so that it will loop though each newline in $HTTP_LINKS and not just the words in the string. (I don't want to use a for loop with IFS set to \n) I thought maybe I could

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

心不动则不痛 提交于 2019-12-04 14:07:17
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 = [ ['X', '1498393', '1'], ['Y', '1549668', '-82', '-80', '-80', '3', '3', '2', ''], ['Y', '1452925', '-87

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

最后都变了- 提交于 2019-12-04 13:46:10
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.delim(file.name, skip=first.line-1, ...)) } However, these logfiles are quite big, and so reading the file

How to create mysql event inside a procedure or trigger?

删除回忆录丶 提交于 2019-12-04 09:38: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 insert and usually enddate is three days later. I would like to create a mysql event that stops the

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

纵饮孤独 提交于 2019-12-04 08:47:04
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 even being printed at all, let alone together. I tried making this regex myself: re.compile(r'''(, | "[^

Ruby : How can I detect/intelligently guess the delimiter used in a CSV file?

我的梦境 提交于 2019-12-04 08:17:36
I need to be able to figure out which delimiter is being used in a csv file (comma, space or semicolon) in my Ruby project. I know, there is a Sniffer class in Python in the csv module that can be used to guess a given file's delimiter. Is there anything similar to this in Ruby ? Any kind of help or idea is greatly appreciated. Looks like the py implementation just checks a few dialects: excel or excel_tab. So, a simple implementation of something that just checks for "," or "\t" is: COMMON_DELIMITERS = ['","',"\"\t\""] def sniff(path) first_line = File.open(path).first return nil unless first

How to read comma separated integer inputs in java

試著忘記壹切 提交于 2019-12-04 06:57:20
import java.io.*; import java.util.*; class usingDelimiters { public static void main(String args[]) { Scanner dis=new Scanner(System.in); int a,b,c; a=dis.nextInt(); b=dis.nextInt(); c=dis.nextInt(); System.out.println("a="+a); System.out.println("b="+b); System.out.println("c="+c); } } This program is working fine when my input is 1 2 3 (separated by space) But, how to modify my program when my input is 1,2,3 (separated by commas) you can use the nextLine method to read a String and use the method split to separate by comma like this: public static void main(String args[]) { Scanner dis=new

Where IN a Comma delimited string [duplicate]

大兔子大兔子 提交于 2019-12-04 06:01:41
This question already has answers here : Closed 4 years ago . Passing a varchar full of comma delimited values to a SQL Server IN function (22 answers) I would like retrieve a certain users from a full list of a temp table #temptable. The query is like this: DECLARE @List varchar(max) SELECT @List = coalesce(@List + ',','') + '''' + StaffCode + '''' FROM tblStaffs SELECT UserName FROM #temptable WHERE #temptable.StaffCode IN (@List) I can tell @List is in a right format: 'AAA','ABB','BBB','CCC','DDD','MMM' And if I change it to WHERE #temptable.StaffCode IN ('AAA','ABB','BBB','CCC','DDD','MMM'