delimiter

Bash - how to preserve newline in sed command output?

[亡魂溺海] 提交于 2019-12-01 18:22:21
Assuming I have a file BookDB.txt which stores data in the following format : Harry Potter - The Half Blood Prince:J.K Rowling:40.30:10:50 The little Red Riding Hood:Dan Lin:40.80:20:10 Harry Potter - The Phoniex:J.K Rowling:50.00:30:20 Harry Potter - The Deathly Hollow:Dan Lin:55.00:33:790 Little Prince:The Prince:15.00:188:9 Lord of The Ring:Johnny Dept:56.80:100:38 Three Little Pig:Andrew Lim:89.10:290:189 All About Linux:Ubuntu Team:76.00:44:144 Catch Me If You Can:Mary Ann:23.60:6:2 Python for dummies:Jared Loo:15.99:1:10 I am trying to replace the (:) delimiter with (, ) in my output. It

How to import a flat file without changing regional settings on the deployment server?

浪子不回头ぞ 提交于 2019-12-01 17:15:09
I am trying to read a text file in SSIS (2005/2008). I created a connection to the file and placed flat file source, and it works fine in preview but when I try to run I get error saying: [Derived Column [91848]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR So I have identified that there are couple of columns with decimal numbers which use period as delimiters. But since I work in Scandinavian environment, the servers expect comma as delimiters. What works is manually changing delimiter from comma to period in regional settings on the windows server but this is not an adequate

strtok() issue: If tokens are delimited by delimiters,why is last token between a delimiter and the null '\0'?

百般思念 提交于 2019-12-01 16:47:02
问题 In the following program, strtok() works as expected in the major part but I just can't comprehend the reason behind one finding. I have read about strtok() that: To determine the beginning and the end of a token, the function first scans from the starting location for the first character not contained in delimiters (which becomes the beginning of the token). And then scans starting from this beginning of the token for the first character contained in delimiters, which becomes the end of the

Stop ConfigParser adding spaces to delims after upgrade from python 2.7.3 to 2.7.9

扶醉桌前 提交于 2019-12-01 14:06:57
After being forced to use a later version of python, ConfigParser now insists on adding spaces to each side of any delims when modifying a configuration file. e.g. setting=90 becomes: setting = 90 This was not the behavior in the earlier version, and I cannot find a way of controlling this behavior, can anyone help? My test code looks like this: import ConfigParser import os config = ConfigParser.ConfigParser() cfgfile = '/home/osmc/bin/test/config.txt' os.system('sudo echo "[section]" > ' + cfgfile) os.system('sudo echo "setting=0" >> ' + cfgfile) config.read(cfgfile) config.set('section',

Implementing `strtok` whose delimiter has more than one character

你。 提交于 2019-12-01 12:22:36
Code snippet: char str[] = "String1::String2:String3:String4::String5"; char *deli = "::"; char *token = strtok(str,deli); while(token != NULL) { printf("Token= \"%s\"\n", token); token=strtok(NULL,deli); } The above code snippet produces the output: Token="String1" Token="String2" Token="String3" Token="String4" Token="String5" but I want the output to be: Token="String1" Token="String2:String3:String4" Token="String5" I know that I am not getting the expected output because each character in the second argument of strtok is considered as a delimiter. To get the expected output, I've written

Stop ConfigParser adding spaces to delims after upgrade from python 2.7.3 to 2.7.9

巧了我就是萌 提交于 2019-12-01 11:47:52
问题 After being forced to use a later version of python, ConfigParser now insists on adding spaces to each side of any delims when modifying a configuration file. e.g. setting=90 becomes: setting = 90 This was not the behavior in the earlier version, and I cannot find a way of controlling this behavior, can anyone help? My test code looks like this: import ConfigParser import os config = ConfigParser.ConfigParser() cfgfile = '/home/osmc/bin/test/config.txt' os.system('sudo echo "[section]" > ' +

need a shell script to change the comma delimiter to a pipe delimeter

只愿长相守 提交于 2019-12-01 11:28:05
My input looks like "$130.00","$2,200.00","$1,230.63" and so on My question is how can I go about changing the comma delimiter to a | delimiter without getting rid of the comma in the actual input. Just to clarify this input is in a csv file with 40 columns and 9500 rows. I want my output to look like "$130.00"|"$2,200.00"|"$1,230.63" To do this reliably, you have to use states to keep track of wether you are inside a string or not. The following perl script should work: #!/usr/bin/perl -w use strict; use warnings; my $state_outside_string = 0; my $state_inside_string = 1; my $state = $state

Regex to match only innermost delimited sequence

大憨熊 提交于 2019-12-01 10:31:53
I have a string that contains sequences delimited by multiple characters: << and >> . I need a regular expression to only give me the innermost sequences. I have tried lookaheads but they don't seem to work in the way I expect them to. Here is a test string: 'do not match this <<but match this>> not this <<BUT NOT THIS <<this too>> IT HAS CHILDREN>> <<and <also> this>>' It should return: but match this this too and <also> this As you can see with the third result, I can't just use /<<[^>]+>>/ because the string may have one character of the delimiters, but not two in a row. I'm fresh out of

need a shell script to change the comma delimiter to a pipe delimeter

萝らか妹 提交于 2019-12-01 07:36:37
问题 My input looks like "$130.00","$2,200.00","$1,230.63" and so on My question is how can I go about changing the comma delimiter to a | delimiter without getting rid of the comma in the actual input. Just to clarify this input is in a csv file with 40 columns and 9500 rows. I want my output to look like "$130.00"|"$2,200.00"|"$1,230.63" 回答1: To do this reliably, you have to use states to keep track of wether you are inside a string or not. The following perl script should work: #!/usr/bin/perl

Regex to match only innermost delimited sequence

为君一笑 提交于 2019-12-01 06:19:08
问题 I have a string that contains sequences delimited by multiple characters: << and >> . I need a regular expression to only give me the innermost sequences. I have tried lookaheads but they don't seem to work in the way I expect them to. Here is a test string: 'do not match this <<but match this>> not this <<BUT NOT THIS <<this too>> IT HAS CHILDREN>> <<and <also> this>>' It should return: but match this this too and <also> this As you can see with the third result, I can't just use /<<[^>]+>>/