Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
The figure is given to show the output after requesting the URL and removing all the div element tags. I now need to store the data of Area, Bedroom, Location, Price, the floor in a CSV file. So how can I do it I only know python's function and method for doing it and how can I perform Indexing in such output?
Output by some manipulation done in URL request which is to be stored in CSV file
List item
#shivani Karna, there are many options here. Here are two approaches I would consider:
open a file a context manager to write to and write each found element on a new line:
https://www.w3schools.com/python/python_file_write.asp
parse the elements into a dictionary and then write the contents to a pandas dataframe, then to a csv file for a readable format:
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
What's a simple and performat way to save online published lists of IP addresses like this one in a standard python list? Example
ip_list = ['109.70.100.20','185.165.168.229','51.79.86.174']
HTML parsing library beautifulsoap seems way to sophisticated for the simple structure.
Its not that beautifulsoup is too sophisticated, its that the content type is text, not html. There are several APIs for downloading content, and requests is popular. If you use its text property, it will perform any decoding and unzipping needed
import requests
resp = requests.get("https://www.dan.me.uk/torlist/")
ip_list = resp.text.split()
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
There must be a simple solution to this question:
"Create a .pdf file from various other .pdf files w/ navigable index and page numbers via python."
All files are in the same folder, and all are .pdf files.
I want each filename to contain in the index and the index as a starting page.
What packages do you think fits my needs best?
Any thoughts?
https://pythonhosted.org/PyPDF2/
You have to split each page that you want and to add to your new pdf file.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am currently working on a python project and I would like to know how to serve a txt file to a browser. Ex: Accessing page.html will make a get request for a file with the same name to download. No FE processing is needed for the received file. Thanks!
You have to change the MIME type of the content. Take a look at MDN docs provided below.
the list of current content types accepted
One option that i would recommend it's application/octet-stream.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have no idea if this is possible, I want to know if it's possible to use Python dicts to read JSON, I have crawled the web for answers, but I don't think anyone has had the same idea, or it's just not possible. It may be a confusing question, But, here it goes!
I have a Python Dict as;
dict1 = {"3.8.1":"data[0]['3.8.1']","3.8":"data[1]['3.8']"}
As you can see, It'd get the json request string from the first dict with the found wordpress version number
dict1["3.8.1"]
would return the required next section to read from the loaded JSON file
I didn't "think" it was possible, but I thought I'd ask. As you can see in the above dict, It contains a way I could possibly request from the loaded JSON.
Anyway, any input, or other ways I could do it would be great, Thanks.
Are you looking for exec()?
exec("myvar = " + dict1["3.8.1"])
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying to read the below pdf file and I need to save each and every article in seperate file.
https://dl.dropboxusercontent.com/u/23092311/sample.pdf
A article can be in one or more than one pages. I have used PDFMiner to convert the entire pdf to txt file. But I don't know how to convert into multiple articles.
I am new to Python. Please provide a best method or sample code to extract the each and every articles separately?
I'll be honest. I've never used PDFMiner before, but if you already have the PDF into a text file, couldn't you just parse the text file into a string, and then use the split function to divide the string into different articles based on "The New York Times" heading? I guess that assumes PDFMiner is capable of reading that fancy font which I don't know if that is possible.
Looking at the file you provided, you could something like the following:
reading = open('test.txt')
full_paper = reading.read()
split_paper = full_paper.split('Copyright 2014 The New York Times Company. All Rights Reserved.')
split_paper would then be an array containing your articles in indexes 1, 2, 3, 4, 5, 6 (index 0 would contain the initial heading). You'd have to do some other string cleanup to get the exact articles, but that should at least get you started.
Make sense?