I'm looking for a regex that will parse a line at a time from a csv file. basically, what string.readline() does, but it will allow line breaks if they are within double quotes.
or is there an easier way to do this?
I have the following JSON text that i need to parse to get pageName, pagePic, post_id, etc.
What is the required code?
{
pageInfo: {
pageName: abc
pagePic: http://profile.ak.fbcdn.net/object2/367/65/q160119538822_4127.jpg
}
posts: [
{
post_id: 160119538822_302076968822
actor_id: 1183856639
picOfPersonWhoPosted: http://profile.ak.fbcdn.net/hprofile-ak-sf2p/hs302.ash1/23104_1183856639_4894_q.jpg
nameOfPersonWhoPosted: Andrea Raquel
message: Sounds cool. Can't wait to see it!
likesCount: 2
comments: [
]
timeOfPost: 1266036226
}
Hello!
I have list of IPs:
238.51.208.96/28
238.51.209.180-199
238.51.209.100-109
238.51.213.2-254
...
How can I easily parse them? I need first and last IP from range.
For First line I can use Net::Netmask CPAN module, but what can I do with others lines?
Trying to parse a csv file that has all the data wrapped in double quotes, because there may be commas in the double quotes.
Looks like this:
$songs = '"1, 2, 3, 4 (I Love You)","Plain White T's","CBE10-22",15,"CBE10-22","","","CB",984,"","10/05/10"';
$regResult = preg_match( "", $songs, $matches );
I can't figure out a regex that will return the data between the quotes as the matches. I'm sure there is some regex master that can help me with this.
What is the best way to parse a float in CSharp?
I know about TryParse, but what I'm particularly wondering about is dots, commas etc.
I'm having problems with my website. On my dev server, the ',' is for decimals, the '.' for separator. On the prod server though, it is the other way round.
How can I best capture this?
Hi,
I have some non well-formed xml (HTML) data in JAVA, I used JAXP Dom, but It complains.
The Question is :Is there any way to
use JAXP to parse such documents ??
I have a file containing data such as :
<employee>
<name value="ahmed" > <!-- note, this element is not closed, So it is not well-formed xml-->
</employee>
I'd like to be able to use ruby's OptionParser to parse sub-commands of the form
COMMAND [GLOBAL FLAGS] [SUB-COMMAND [SUB-COMMAND FLAGS]]
like:
git branch -a
gem list foo
I know I could switch to a different option parser library (like Trollop), but I'm interested in learning how to do this from within OptionParser, since I'd like to learn the library better.
Any tips?
I've tried everything (every method that shows up on a SO search), but I can't get it to work.
I'm trying to parse this:
questions = (
{
owner = {
"display_name" = "Neil";
};
title = "Initialising ";
"up" = 11;
"view" = 92;
}
);
I'm trying to get the display_name under owner.
From DateTimeFormatter javadoc:
Zone names: Time zone names ('z') cannot be parsed.
Therefore timezone parsing like:
System.out.println(new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy").parse("Fri Nov 11 12:13:14 JST 2010"));
cannot be done in Joda:
DateTimeFormatter dtf = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss z yyyy");
System.out.println(dtf.parseDateTime("Fri Nov 11 12:13:14 JST 2010"));
//Exception in thread "main" java.lang.IllegalArgumentException: Invalid format: "Fri Nov 11 12:13:14 JST 2010" is malformed at "JST 2010"
//at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:673)
I can't parse the JSON that I have no control of. What am I doing wrong here?
data.json
{
"img": "img1.jpg",
"img": "img2.jpg",
"size": [52, 97]
}
{
"img": "img3.jpg",
"img": "img4.jpg",
"size": [52, 97]
}
jquery
$.getJSON("data.json",
function(data){
$.each(data, function(i,item){
alert(item.img[i]);
});
});
Hi, I'm really confused as to why this is kicking up an error?
$admin = substr($_SERVER['REQUEST_URI'], 0, 7);
$account = substr($_SERVER['REQUEST_URI'], 0, 9);
if($admin != '/admin/' || $account != '/account/')
{
}
It is giving this error Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' Why is it doing this?
Thanks
Tom
Hi
I face issue parsing xhtml with DOCTYPE declaration using DOM parser.
Error: java.io.IOException: Server returned HTTP response code: 503 for URL:
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%20
Is there a way to parse the xhtml to a Document object iognoring the DOCTYPE.
Im getting SyntaxError: Parse Error, only on safari. Here is the code in question.
<script type="text/javascript">
//
I am using transloadit a jquery plugin. which works on every other page and is loading fine on safari by the looks of it.
The errors is on line 44 which is
export: {
Can anyone see anything wrong with that page?
I have a two dimensional JSON array where each element contains several attributes. The example below is intentionally simplified:
var map_data = { "1":
{"1":{"name":"aa"},"2":{"name":"bb"}},
"2":
{"1":{"name":"cc"},"2":{"name":"dd"}}
};
I try to parse the data but .length doesn't work:
for(x=1; x<=map_data.length; x++) {
for(y=1; y<=map_data[x].length; y++) {
// CODE
}
}
Many, many thanks!
I am getting the following error when i upload the file to my host server. Same thing works fine in my machine running xampp
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home1/mobyhold/public_html/admin-arabiadc/admin/_product.php on line 1
The Rhino release that is included in Java 6 ScriptEngine does not have a JSON parser. I've tried including crockfords JSON2.js in my script on the scriptengine.eval(). When I try to do the JSON.parse, it ends up giving me a script error that .replace is an unknown function. .replace is referenced several places in JSON2, and it works fine inside a browser (IE7, IE8, FF3). Anyone see this and have a suggestion?
import urllib
import xml.etree.ElementTree as ET
def getWeather(city):
#create google weather api url
url = "http://www.google.com/ig/api?weather=" + urllib.quote(city)
try:
# open google weather api url
f = urllib.urlopen(url)
except:
# if there was an error opening the url, return
return "Error opening url"
# read contents to a string
s = f.read()
tree=ET.parse(s)
current= tree.find("current_condition/condition")
condition_data = current.get("data")
weather = condition_data
if weather == "<?xml version=":
return "Invalid city"
#return the weather condition
#return weather
def main():
while True:
city = raw_input("Give me a city: ")
weather = getWeather(city)
print(weather)
if __name__ == "__main__":
main()
gives error , I actually wanted to find values from google weather xml site tags
Hi,
I am fetching a RSS, in which i receive the following Date stamp:
2010-05-10T06:11:14.000Z
Now i am using NSDateFormatter to parse this datetime stamp.
[parseFormatter setDateFormat:@"yyyy-MM-dTH:m:s.z"];
But its not working fine if just remove the time stamp part it works for the date [parseFormatter setDateFormat:@"yyyy-MM-d"]; But if i add the rest of the stuff it returns nil.
Any idea ?
Thanks in Advance....
Hello,
I need a regular expression to parse a text, the text is a URL. The URL is
http://www.foo.com/bar/hello.txt.
I want to get rid of the hello.txt, the delimiter is the slash.
I would like to get http://www.foo.com/bar/
My goal is to parse HTML with lxml, which supports both XPath and CSS selectors.
I can tie my model properties either to CSS or XPath, but I'm not sure which one would be the best, e.g. less fuss when HTML layout is changed, simpler expressions, greater extraction speed.
What would you choose in such a situation?
Hello All,
I am trying to parse formula in C# language like
"5*3 + 2"
"(3*4 - 2)/5"
Is it possible to do in C# or scripts like VBScript, JavaScript (which will be called in c# program).
Thanks a lot!.
Hi,
Is it possible to parse the enetered text in the textinput,i want to find the entered text contain's @ symbol and . symbol..is it possible?
Thank's in advance....
I'm working on a script to run through a CSV file (see previous post).
I ran into a weird thing, where if my actual CSV file itself has a blank line at the end of it, it will open and parse just fine, but if it doesn't, if the end of the file ends at the end of the last line, it just shows up blank.