To start off: I am not familiar with JSON. I think I understand its purpose and formatting, but I'm not trying to be an expert on the subject (and it would seem as though it isn't a very hard 'subject' to master).
But I've run into a problem. I've been trying to download this option data from google, and I'm forced to download it in JSON format. That's fine and all, and I was just going to run it through a python script anyways, so I don't mind it's format. But, I can't get it to work. After reading into all the errors I've been running into, it would seem as though this data isn't formatted correctly. I'm led to assume that this isn't a JSON file at all, but if it's not, then I don't know what to do with it.
Any help would be appreciated. I can't seem to find any resources on this that doesn't just say that this isn't JSON.
I should also point out that, from my naive familiarity with JSON formatting, it would seem as though the problem is that there are strings without double quotes around them. If this is the only issue, then I would wonder why google wouldn't just fix it, so I'm assuming there is something else at play here.
Admittedly this might not have been the original author's intention but this is actually valid CSON, CoffeeScript's version of JSON. I went ahead and tried cson2json from the cson npm package on the file and it worked out great. Here's the JSON on pastebin.
If you want to do the same yourself in an automated manner you can simply use the cson library, that should cover everything for you.
Related
I have some experience in python and wanted to mess around with audio.
What I specifically wanted to do is change the specific frequencies of live audio and see what the output would be, but I can't seem to find a way to do it.
I was hoping there would be a library I could use since I am no expert, but it seems like my idea is so strange that such a library doesn't exist.
Does someone know how to that?
Greetings,
Neimod
PS: If it's for some reason easier to do in C++, that is an option for me
A frequent and long lurker on here: I usually find my questions answered on here. However, I have come across perhaps a simple, yet vague project that escapes me. I am fairly new to Python (currently using ver 3.6).
I am looking at: https://www.ishares.com/us/products/239726/
From what I can tell, there is some jquery stuff involved here: looking near the "Holdings" portion of the page. Instead of 'Top 10' selected, if 'All' is selected, there is an option to get holdings 'as of.'
If a specific historical month is selected, a prompt to download a .csv is created. What I would like to do is get each csv file that is produced from the drop down list, going back to Sept 29, 2006. In other words, automatically downloading the .csv file that is produced for each request given through this drop down list.
To give some (not necessarily relevant) context, I am familiar with pandas and bs4, and perhaps some other less popular libraries. As background, I keep a couple of desk references: 'Beginning Python' by Magnus Lie Hetland and 'Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython' by Wes McKinney.
I would like some small direction on how to approach this issue that I may be overlooking. In other words, breadcrumbs are helpful, but not asking for anyone to do all this work for me. I would like to explore and learn as much as humanly possible.
What libraries/methods should I perhaps use? I understand this is completely open-ended, so I would like to stick to bs4 and Pandas as much as possible. Other libraries are helpful as well, but those would be the focus.
Thanks!
I would like some small direction on how to approach this issue
Using your browser's developer tools, examine the network requests being made. You will see that, when you choose a historical month, a request is made. If you copy the URL from that request, you can paste it into your browser to see if you can "replay" the request to get the payload. I tested it, and you can. What's more, you can see the query parameters quite clearly. They are not obfuscated. This means you can programatically generate URLs that you can then use cURL or wget on.
Do note that I tried to specify a file type of "csv" and got an empty response, but when I requested a file type of "json" I got the data. YMMV. Good luck!
I am trying to do some research on the wikipedia data, I am good at Python.
I came across this library, seems nice: https://pypi.python.org/pypi/wikipedia/
I don't want to hit wikipedia directly as this is slow, and also I am trying to access a lot of data and might run into their API limits.
Can I somehow hack this to make it access a local instance of wikipedia data. I know I can run a whole wikipedia server and try to do that, but that seems a round about way.
Is there a way to just point to the folder and get this library to work as it does. Or are you aware of any other libraries that do this?
thank you.
I figured out what I need. I think I shouldn't be searching for API, what I am looking for is a parser. Here are a couple options I have narrowed down so far. Both seem like solid starting points.
wikidump:
https://pypi.python.org/pypi/wikidump/0.1.2
mwlib:
https://pypi.python.org/pypi/mwlib/0.15.14
Update: While these are good parsers for wikipedia data, I found them too limiting in one way or the other, not to mention the lack of documentation. So I eventually went with good old python ElementTree and directly work with the XML.
Maybe this is a dumb question, but I don't get it so appologize :)
I have an RTF document, and I want to change it. E.g. there is a table, I want to duplicate a row and change the text in the second row in my code in an object-oriented way.
I think pyparsing should be the way to go, but I'm fiddling around for hours and don't get it. I'm providing no example code because it's all nonsense I think :/
Am I on the right path or is there a better approach?
Anyone did something like that before?
RTFs are text documents with special "symbols" to create the formatting. (see - http://search.cpan.org/~sburke/RTF-Writer/lib/RTF/Cookbook.pod#RTF_Document_Structure It seems that perl has a good RTF library though), so yes, PyParsing is a good way to go. You have to learn the structure and then parse (there are perl code examples in the page i mentioned. If you are lucky you can translate them in python with some effort)
There is a basic RTF module available for python. Check - http://pyrtf.sourceforge.net/
Hope that helps you a little.
I am seeing use of <$nopage> in some python scripts online and in a pdf file. I have googled for what it stands for. But could not get information about it. To be specific, in the PDF version of the book, Core Python Programming, I see this <$nopage> construct many times. But on the online version (Safari Books) of the same book, I do not see this construct. Can someone please tell me what this <$nopage> means? Thanks.
It means nothing in the context of Python at all. It's probably a mistake in the PDF rendering. I'm guessing it's a statement to prevent page breaks in the code.
Update: I finally found an example here:
http://raninho.com.br/~paper/Python/O%27Reilly%20-%20Core%20Python/237.html
That is indeed not python code, but most likely code to prevent page breaks. Pretend it's not there.