text-parsing

Howto clean comments from raw sql file

末鹿安然 提交于 2020-01-01 08:44:48
问题 I have problem with cleaning comments and empty lines from already existing sql file. The file has over 10k lines so cleaning it manually is not an option. I have a little python script, but I have no idea how to handle comments inside multi line inserts. Code: f = file( 'file.sql', 'r' ) t = filter( lambda x: not x.startswith('--') \ and not x.isspace() , f.readlines() ) f.close() t #<- here the cleaned data should be How it should work: This should be cleaned: -- normal sql comment This

Howto clean comments from raw sql file

流过昼夜 提交于 2020-01-01 08:44:26
问题 I have problem with cleaning comments and empty lines from already existing sql file. The file has over 10k lines so cleaning it manually is not an option. I have a little python script, but I have no idea how to handle comments inside multi line inserts. Code: f = file( 'file.sql', 'r' ) t = filter( lambda x: not x.startswith('--') \ and not x.isspace() , f.readlines() ) f.close() t #<- here the cleaned data should be How it should work: This should be cleaned: -- normal sql comment This

Strategy for parsing natural language descriptions into structured data

穿精又带淫゛_ 提交于 2020-01-01 08:19:10
问题 I have a set of requirements and I'm looking for the best Java-based strategy / algorthm / software to use. Basically, I want to take a set of recipe ingredients entered by real people in natural english and parse out the meta-data into a structured format (see requirements below to see what I'm trying to do). I've looked around here and other places, but have found nothing that gives a high-level advice on what direction follow. So, I'll put it to the smart people :-): What's the best /

Can I transpose a file in Vim?

家住魔仙堡 提交于 2019-12-31 13:12:13
问题 I know I can use AWK but I am on a Windows box. I am making a function for others that may not have AWK. I also know I can write a C program but I would love not have to create maintain and compile something for a little Vim utility I am making. The original file might be THE DAY WAS LONG THE WAY WAS FAST and it would become TT HH EE DW AA YY WW AA SS LF OA NS GT UPDATE: Golf rules apply to selecting correct answer. UPDATE: Python fans should check out Mr. Duffy's answer below. 回答1: Here is a

R: read and parse Json

ε祈祈猫儿з 提交于 2019-12-25 07:59:36
问题 If R is not suitable for this job then fair enough but I believe it should be. I am calling an API, then dumping the results into Postman json reader. Then I get results like: "results": [ { "personUuid": "***", "synopsis": { "fullName": "***", "headline": "***", "location": "***", "image": "***", "skills": [ "*", "*", "*", "*.", "*" ], "phoneNumbers": [ "***", "***" ], "emailAddresses": [ "***" ], "networks": [ { "name": "linkedin", "url": "***", "type": "canonicalUrl", "lastAccessed": null

check csv for blank fields and write output if exist blank

╄→尐↘猪︶ㄣ 提交于 2019-12-25 03:26:39
问题 This is a csv example: 1- 2018-11-07,hostname-184,IP_INFO, 10.2334.40.334, 255.255.255.0, 2 - 2018-11-07,hostname-184,IP_INFO, 334.204.334.68, 255.255.255.0, 3- 2018-11-07,hostname,7.1.79-8,IP_INFO, 142.334.89.3342, 255.255.255.0, 4- 2018-11-07,hostname,7.1.80-7,IP_INFO, 13342.221.334.87, 255.255.255.0, 5- 2018-11-07,hostname-155,IP_INFO, 142.2334.92.212, 255.255.255.0, 6 - 2018-11-07,hostname-184,IP_INFO, , , 1 7- 2018-11-07,hostname-184,IP_INFO, 10.19334.60.3343, 255.255.255.0, so how can i

Text file parsing using java, suggestions needed on which one to use

浪尽此生 提交于 2019-12-24 13:33:33
问题 I can successfully read text file using InputFileStream and Scanner classes. It's very easy but I need to do something more complex than that. A little background about my project first.. I have a device with sensors, and I'm using logger that will log every 10sec data from sensors to a text file. Every 10 sec its a new line of data. So what I want is when I read a file is to grab each separate sensor data into an array. For example: velocity altitude latitude longitude 22 250 46.123245 122

Perl - Reading Specific Lines from a CSV file

做~自己de王妃 提交于 2019-12-24 05:52:03
问题 I'm looking to read a certain "category" from a .csv file that looks something like this: Category 1, header1, header2, header3,..., , data, data, data,..., , data, data, data,..., , data, data, data,..., Category 2, header1, header2, header3,..., , data, data, data,..., , data, data, data,..., , data, data, data,..., Category 3, header1, header2, header3,..., , data, data, data,..., , data, data, data,..., , data, data, data,... Let's say I wanted to print only the data from a specific

List files on HTTP/FTP server in R

爷,独闯天下 提交于 2019-12-23 12:24:03
问题 I'm trying to get list of files on HTTP/FTP server from R!, so that in next step I will be able to download them (or select some of files which meet my criteria to download). I know that it is possible to use external program in web browser (download manager) which will allow me to select files to download from current web page/ftp. However, I wish to have everything scripted, so that it will be easier for me to reproduce. I thought about calling Python from R! (since it seems much easier),

How can I split out individual column values from each line in a text file?

谁都会走 提交于 2019-12-23 03:50:57
问题 I have lines in an ASCII text file that I need to parse. The columns are separated by a variable number of spaces, for instance: column1 column2 column3 How would i split this line to return an array of only the values? thanks 回答1: String testvar = "Some Data separated by whitespace"; String[] vals = testvar.split("\\s+"); \s means a whitespace character, the + means 1 or more. .split() splits a string into parts divided by the specified delimiter (in this case 1 or more whitespace characters