string-parsing

MYSQL: How to search and replace data in one table a table with column from another table using a REGEXP

好久不见. 提交于 2019-12-11 19:39:22
问题 Here's the basic idea of what I need to do. I have two tables like the following: Table A Table B |id|name | |id|sentence | |1 |hello | |1 |I like to say hello | |2 |world | |2 |The world is large | |3 |hello world| |3 |lorem hello ipsum world lorem ipsum hello world| I need to cycle through the rows in Table A to look for each name in Table B. Then I want to use a REGEXP in Table B to replace the word if it is found. For example if hello is found in Table B it will replace the word hello in

Parsing file and detection of pattern in Java

孤街浪徒 提交于 2019-12-11 16:43:19
问题 My problem is quite simple, i am parsing a CSV file, line after line and i want to get the values of the columns. The separators used are simply " ; ", but my file can have quite a lot of columns, and they won't be always in the same order. So as example for my .CSV file : time;columnA;columnB,ColumnC 27-08-2013 14:43:00; this is a text; this too; same here And i would like to be able to get all the values of time, columnA, columnB and columnC. What would be the easiest way? I used

I am very confused on how to parse multiple delimiters using getline and strtok in c++

守給你的承諾、 提交于 2019-12-11 13:11:35
问题 My code is posted below. I want to be able to parse using the delimiters " ()," and convert the strings into integers in cpp. while(getline(fin, line)) { x = atoi((strtok(line.c_str(),'(,)')); xx = atoi((strtok(NULL,"(),")); xxx = atoi((strtok(NULL,"(),"))); cout << x << " " << xx << " " << xxx << "\n"; } but for some reason I get the following errors GraphTest.cpp:134: error: invalid conversion from ‘const char*’ to ‘char*’ GraphTest.cpp:134: error: initializing argument 1 of ‘char* strtok

Splitting complex String Pattern (without regex) in a functional approach

爷,独闯天下 提交于 2019-12-11 09:54:33
问题 I am trying to split a string without regex in a more idiomatic functional approach. case class Parsed(blocks: Vector[String], block: String, depth: Int) def processChar(parsed: Parsed, c: Char): Parsed = { import parsed._ c match { case '|' if depth == 0 => parsed.copy(block = "", blocks = blocks :+ block , depth = depth) case '[' => parsed.copy(block = block + c, depth = depth + 1) case ']' if depth == 1 => parsed.copy( block = "", blocks = blocks :+ (block + c), depth = depth - 1) case ']'

Parsing File name of a doc file of java

非 Y 不嫁゛ 提交于 2019-12-11 09:17:49
问题 I want to parse the file names of multiple doc files (MS office) using java. How should I go about doing this? I was able to find an API on extracting info from the doc itself, but I can't find information on the file name itself. So say I have a doc file XX_232312_22 , I want to just parse the file name (ie 232312 part). EDIT: What would we do if we need to parse more than just one file? For instance, all 1000 files in one directory? 回答1: String[] parts = filename.split("-"); parts[0] //

Best way to read lines in groups in a flat file

╄→гoц情女王★ 提交于 2019-12-11 02:39:31
问题 I have a file which consists of the groups of lines. Each group represents a event. The end of the group is denoted by "END". I can think of using a for loop to loop through the lines, store the intermediate lines and emit the group when "END" is encounter. But since I would like to do it in Scala. I am wondering if someone can suggest a more functional way to accomplish the same thing? ---------- A B C END ---------- D E F END ---------- 回答1: Just define an iterator to return groups def

Splitting Delimited String vs JSON Parsing Efficiency in JavaScript

笑着哭i 提交于 2019-12-10 17:26:34
问题 I need to retrieve a large amount of data (coordinates plus an extra value) via AJAX. The format of the data is: -72.781;;6,-68.811;;8 Note two different delimiters are being used: ;; and , . Shall I just return a delimited string and use String.split() (twice) or is it better to return a JSON string and use JSON.parse() to unpack my data? What is the worst and the best from each method? 回答1: Even if the data is really quite large, the odds of their being a performance difference noticeable

Getting domain in AS3

ε祈祈猫儿з 提交于 2019-12-10 15:15:52
问题 I know how to get the URL of the page, but how can I extract simply the domain and the domain alone? It must return the same value with or without www, and it must also return the same value regardless of file, with or without trailing slash, etc. So www.domain.com would return domain.com , and domain.com/index.php would return the same as well. Is this possible? If so, is there a way to do it without calling ExternalInterface.call('window.location.href.toString') ? Thank you for the help!

C# - How to parse text file (space delimited numbers)?

℡╲_俬逩灬. 提交于 2019-12-10 14:13:28
问题 Given a data file delimited by space, 10 10 10 10 222 331 2 3 3 4 45 4 2 2 4 How to read this file and load into an Array Thank you 回答1: var fileContent = File.ReadAllText(fileName); var array = fileContent.Split((string[])null, StringSplitOptions.RemoveEmptyEntries); if you have numbers only and need a list of int as a result, you can do this: var numbers = array.Select(arg => int.Parse(arg)).ToList(); 回答2: It depends on the kind of array you want. If you want to flatten everything into a

How to work with data from NBA.com?

风格不统一 提交于 2019-12-10 11:07:47
问题 I found Greg Reda's blog post about scraping HTML from nba.com: http://www.gregreda.com/2015/02/15/web-scraping-finding-the-api/ I tried to work with the code he wrote there: import requests import json url = 'http://stats.nba.com/stats/leaguedashteamshotlocations?Conference=&DateFr' + \ 'om=&DateTo=&DistanceRange=By+Zone&Division=&GameScope=&GameSegment=&LastN' + \ 'Games=0&LeagueID=00&Location=&MeasureType=Opponent&Month=0&OpponentTeamID' + \ '=0&Outcome=&PORound=0&PaceAdjust=N&PerMode