Tagged Questions
0
votes
1answer
12 views
element tree treats similar files differently
Here are two different files that my python (2.6) script encounters. One will parse, the other will not. I'm just curious as to why this happens.
This xml file will not parse and the script will ...
1
vote
3answers
55 views
python: algorithm to filter almost same text
I have a list of strings (topics on forum), like:
"[John Smith] Hello my friend 1080p"
"It was him! by Ronnie"
"new: Hello, my friend, J. Smith"
"Askade la bonko"
...
"Smith John: Hello my friend! ...
-1
votes
1answer
20 views
Getting items from rss in python [closed]
I'm trying to get a list of all "link" items from this feed:
http://www.ezrss.it/feed/
Here's what I have so far as pseudo code.
from xml.dom import minidom
f = open('c:/torrents/download.xml', ...
0
votes
2answers
63 views
How can I strip the first 14 characters in an list element using python?
I have a txt file, from which I need to search a specific line, which is working, but in that line I need to strip the first 14 characters, and the part of the list element I am interested is ...
0
votes
1answer
19 views
Python Urllib Urlopen won't return after new line?
I'm trying to get authenticated by an API I'm attempting to access. I'm using urllib.parse.urlencode to encode the parameters which go in my URL. I'm using urllib.request.urlopen to fetch the content.
...
0
votes
1answer
43 views
match numbers in multiple lines
I have an HTML text like this
<tr>
<td><strong>Turnover</strong></td>
<td width="20%" class="currency">£348,191</td>
...
1
vote
1answer
45 views
Python 3 replacement of string regex
I am working with a html script converted into a string
How do I replace all the html code in tags with blank using regex?
3
votes
7answers
124 views
How to parse a string and return a nested array?
I want a Python function that takes a string, and returns an array, where each item in the array is either a character, or another array of this kind. Nested arrays are marked in the input string by ...
0
votes
1answer
29 views
Trouble parsing xml archive using Element Tree
Python + programming noob here, so you may have to bear with me. I have a number of xml files (RSS archives) and I want to extract news article urls from them. I'm using Python 2.7.3 on Windows... and ...
1
vote
2answers
40 views
find string of arbitrary length before a known string
Just say I have a string such as:
Lecture/NNP/B-NP/O delivered/VBD/B-VP/O at/IN/B-PP/B-PNP the/DT/B-NP/I-PNP UNESCO/NNP/I-NP/I-PNP House/NNP/I-NP/I-PNP in/IN/B-PP/B-PNP Paris/NNP-LOC/B-NP/I-PNP
I ...
3
votes
3answers
62 views
Parsing data from text file
I have a text file that has content like this:
******** ENTRY 01 ********
ID: 01
Data1: 0.1834869385E-002
Data2: 10.9598489301
Data3: ...
0
votes
1answer
27 views
Parse Python Configuration File for Java Programs
I have not found anything of this sort on Google and would like to know if there is a quicker way of doing the following:
I need to parse build scripts for Java programs which are written in Python. ...
4
votes
5answers
103 views
How can I get data from other websites? [closed]
I want to create a website that sustracts information from other websites and print them into my website, I am on research step, so I would like to hear some opinions and what's the best solution to ...
2
votes
3answers
56 views
Searching text in a PDF using Python?
Problem
I'm trying to determine what type a document is (e.g. pleading, correspondence, subpoena, etc) by searching through its text, preferably using python. All PDFs are searchable, but I haven't ...
1
vote
3answers
48 views
Python parse words from URL string
I have a large data set of urls and I need a way to parse words from the urls eg:
realestatesales.com -> {"real","estate","sales"}
I would prefer to do it in python. This seems like it should ...
0
votes
1answer
25 views
Questions about HTML parsing
This is a program we've written for html parsing.
It works perfectly.
We found a demo program on the net, and we modified it for our needs.
But we don't understand how it works.
import urllib
from ...
0
votes
0answers
20 views
Converting Parser element to Class Object
I Have tried out the following code for Converting parser element to a class object
But it did n't work properly ..... Hope some one can help me to solve it ...
import xml.etree.ElementTree as ET
...
0
votes
2answers
39 views
python - parse string (which is an array) returned from a web service as array/list
I am using
httplib.HTTPConnection(self._myurl)
conn.request("GET", "/")
data = conn.getresponse().read()
now this URL returns an python type arrays similar to the below:
[1,"apple",23,"good"]
...
0
votes
3answers
37 views
How to parse a python Loops using a python script?
My main objective is to parse python loops such that i can insert few statements for my analysis.
Normal code:
#A.py
[code Starts]
.
.
.
while [condition]:
[statements]
[statements]
...
-1
votes
1answer
47 views
Parse data from 2 log files in Python [closed]
I need to parse thread number, run number and test number from file1, match the test number in file2 and write both these values into a new file.
The first file has the following content:
com-0 ...
0
votes
1answer
33 views
read multiple lines from one TSV file and based on column append data with comma
How do we parse data based on column index from TSV file?
Once we read data from file then we must have to check column 0 line 1 data with column 0 line 2 data and if it's matching then get column 1 ...
1
vote
3answers
54 views
Efficient Parser for large XMLs
I have very large XML files to process. I want to convert them to readable PDFs with colors, borders, images, tables and fonts. I don't have a lot of resources in my machine, thus, I need my ...
1
vote
2answers
73 views
Parsing multiple lines in Python
I'm currently learning Python and I need to write a program which determines the word which appears the most times in a poem. Problem which is troubling me is about parsing a lines of a poem into a ...
3
votes
2answers
79 views
Python 3 Finding the last number in a string
How can I find the last number in any big string?
For eg in the following string I want 47 as the output:
'tr bgcolor="aa77bb"td>font face="verdana"color="white" ...
3
votes
1answer
95 views
Python 3 Regex Last Match
How do I grab the 123 part of the following string using Python 3 regex module?
....XX (a lot of HTML characters)123
Here the ... Part denotes a long string consisting of HTML characters, words and ...
0
votes
1answer
26 views
parsing xml tags in a specific order in python
I want to load some tags with a specified order from an xml file into python as below:
<data>
<testset name="ts1" order="1" descrption="this is ts1 descrption">
<testcase ...
2
votes
1answer
16 views
Parse elements out of markdown
I want to parse markdown files for specific elements (such as links) and get values out of those elements, and I fail to find a way for that using python-markdown package.
Is it possible to do it ...
0
votes
1answer
23 views
Python: Unable to access macro in Jinja
I am trying to use a macro in a jinja file. Here is my code:
{{ display(class = "hello") }}
{% macro display(class) %}
this is a macro
{% endmacro %}
It's pretty simple, and from what I have ...
0
votes
2answers
54 views
parsing file with curley brakets
I need to parse a file with information separated by curly brackets, for example:
Continent
{
Name Europe
Country
{
Name UK
Dog
{
Name Fiffi
Colour Gray
}
Dog
{
Name Smut
Colour Black
}
...
3
votes
3answers
75 views
log file parsing python
I have a logfile with arbitratry number of lines. All I need is to extract is one line of data from the log file which starts with a string “Total”. I do not want any other lines from the file.
How ...
1
vote
3answers
61 views
Python: variable “tricking” try-exception, but works for if statement
I know the title seems crazy, but it is true. Here is my predicament. First, I am still a beginner at Python so please be considerate. I am trying to test if a variable exists. Now the variable ...
0
votes
2answers
70 views
Unable to parse into JSON object in Python
I have search every where but no one stated this error before.
The obj will return a unicode object but it will return the following error
Exception Type: AttributeError
Exception ...
0
votes
2answers
43 views
using numerical filters to define what print list is used (I assume if filters)
I have some code which parses an xml file obtained from a url, using the following code:
pattern4 = re.compile('title=\'Naps posted: (.*) Winners:')
pattern5 = re.compile('Winners: (.*)\'><img ...
0
votes
0answers
37 views
Searching for multiple kinds of tags at once using Beautiful Soup 4
I am trying to use find_all to get all of the instances of several tag types (I don't care about class), in order, for a bit of soup using bs4.
I want to do something like this:
...
-4
votes
0answers
26 views
Parse csv file python or bash [closed]
I need to parse a CSV file.
I would like to use python or bash but I can not find anything that would be suitble.
In the CSV file if it containts a keyword in col 6 for any of the rows i would like ...
0
votes
0answers
23 views
Python - how to use optparse callback in order to change an int variable and then use it
I want to add options to my python program, such that the user will enter his choice (-c, -l, -lc, etc...) and my optparse will add the choices in prime numbers or something in order to know what the ...
0
votes
1answer
34 views
Giving each data set a name
So I have a code
print
latOne = dL[1][3]
lonOne = dL [1][4]
x = [calculateDistance(latOne, lonOne, latTwo, lonTwo ) for latTwo, lonTwo in zip(latitude, longitude)]
print x
this produces distance ...
0
votes
2answers
23 views
Escaped Strings in Parsing Expression Grammars
I am attempting to write a grammar for a small language utility using the python library parsimonious, but I am struggling with writing a part, which covers strings, especially strings with escaped ...
2
votes
1answer
40 views
Robust json parser in Python or Java
I'm looking for a robust json parser in either Python or Java (so far, I've been working with Python, but as I'm using it to analyze a Java benchmark, using Java is a reasonable alternative.)
Robust ...
4
votes
1answer
35 views
How to extract particular key from HTTP cookies in Python?
Trying to get a particular value from the cookie string of an HTTP request in Python. I believe possibly using the requests library or urllib2 would be a good idea.
Example:
Assume
...
-1
votes
1answer
45 views
Script STOPS when Source URL is not Status 200
I have a script (see below) that checks (more or less) linkpositions on a website, it works fine but as soon as the source url on which the link lies is not a 200 response it will quit, I just want it ...
3
votes
1answer
51 views
Algorithm for parsing expressions in python?
I have next algorithm for parsing expressions in Python:
def parse(strinput):
for operator in ["+-", "*/"]:
depth = 0
for p in range(len(strinput) - 1, -1, -1):
if strinput[p] == ')': ...
0
votes
1answer
32 views
Regular expression to replace “escaped” characters with their originals
NOTE: I'm not parsing lots of or html or generic html with regex. I know that's bad
TL;DR:
I have strings like
A sentence with an exclamation\! Next is a \* character
Where there are "escaped" ...
0
votes
3answers
56 views
python matching list items
I'm using python 2.6
current output
mylist = [('log:A', '1009.2'), ('log:B', '938.1'), ('log:C', '925.7'), ('log:C', '925.7')]
I'am trying to add the values to produce the follow:
Ranked highest to ...
-6
votes
1answer
67 views
python career statistic final
I'm building a top 10 list of career statistics in python 2.6
html_log:jeff 1153.3 1.84 625:54 1 2 71 3 2 10 7:58 499 3 5 616:36 241 36
html_log:fred 28.7 1.04 27:34 -10 18 13 0:48 37 18 8 -3.63
...
2
votes
2answers
68 views
python statistic top 10
using python 2.6
I have large text file.
Below are the first 3 entries, but there are over 50 users I need to check.
html_log:jeff 1153.3 1.84 625:54 1 2 71 3 2 10 7:58 499 3 5 616:36 241 36 ...
0
votes
2answers
30 views
Why does this python procedure not produce an output after I have parsed the JSON file?
Using this json data I parsed the information correctly but after assigning the parsed data to a variable and running it through the procedure I dont get an output, why?
{"maps":[{"id":"blabla i am ...
2
votes
3answers
61 views
splitting a dot delimited string into words but with a special case
Not sure if there is an easy way to split the following string:
'school.department.classes[cost=15.00].name'
Into this:
['school', 'department', 'classes[cost=15.00]', 'name']
Note: I want to ...
0
votes
1answer
17 views
Python XML iterate over multiple blocks
I have an python XML parsing problem that I can't seem to figure out.
I have the following XML:
<data>
<data_in base="base64">
</data_in>
<log_sense_data>
<ds ...
0
votes
1answer
20 views
Edit content in BeautifulSoup ResultSet
My goal in the end is to add up the number within the BeautifulSoup ResultSet down here:
[<span class="u">1,677</span>, <span class="u">114</span>, <span ...