shadrock / code-snippets Goto Github PK
View Code? Open in Web Editor NEWBits and pieces of code I find helpful.
Bits and pieces of code I find helpful.
I'm trying to create a function that will traverse multiple tables stored in .csv files; find a given word; extract the values for that word in the table (e.g. that word's entire record) along with the headers for the values; and concatenate them all in a new .csv.
I have 3 .csv files that contain information for three different cities: Mumbai, Nairobi, and Jakarta. I want to extract all of the information regarding Nairobi and concatenate it in a separate file. Each, separate, .csv contains the following:
csv1
City | GDP per capita |
---|---|
Mumbai | 123 |
Nairobi | 321 |
Jakarta | 231 |
csv2
City | Population | Pop male | Pop female |
---|---|---|---|
Mumbai | 1,000 | 500 | 500 |
Nairobi | 3,000 | 1,500 | 1,500 |
Jakarta | 2,000 | 1,000 | 1,000 |
csv3
City | ISP per capita |
---|---|
Mumbai | 12 |
Nairobi | 32 |
Jakarta | 23 |
I want the function to result in the following output:
City | GDP per capita | Population | Pop male | Pop female | ISP per capita |
---|---|---|---|---|---|
Nairobi | 321 | 3,000 | 1,500 | 1,500 | 32 |
I am running Python 3.7.1 on a Mac. Most of the time I write scripts in Atom and run them in terminal. However, for a lot of my course preparation and tinkering around I use Anaconda / Jupyter Notebooks. I'm using v 1.9.6.
I am currently working on a web scraping script that involves importing the requests library. When I test the first part of the script I get an error message that suggests a dependency issue between two other Python libraries: urllib3 (v 1.24.1) or chardet (v 2.3.0).
Import the library and run it.
Code and error message are as follows:
import requests
url = 'http://www.showmeboone.com/sheriff/JailResidents/JailResidents.asp'
response = requests.get(url)
html = response.content
print(html)
This results in the following error message:
/anaconda3/lib/python3.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.24.1) or chardet (2.3.0) doesn't match a supported version!
RequestsDependencyWarning)
import
library at all?I've written the Python script found here, to rename files in a given directory. The output should be all files in a folder renamed as follows: IDCE_1, IDCE_2, etc. The script works well with the exception that it starts naming with IDCE_2, and not IDCE_1. Any idea what I'm doing wrong? @willdoran (no idea if tagging you in my private repo will actually do anything at all. But look how official this issue is!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.