Skip to content

Instantly share code, notes, and snippets.

@oostendo
Last active April 10, 2016 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oostendo/e144e0b75480bddd9774d38a180b8fff to your computer and use it in GitHub Desktop.
Save oostendo/e144e0b75480bddd9774d38a180b8fff to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"# This script takes paypal transaction exports and converts them so they can be quickbooks imported\n",
"# \n",
"#todo \n",
"#- CSVs can't be more than 1k transactions\n",
"#- \"gross\" needs commas stripped out "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"data = pd.read_csv(\"Downloads/DHR_ALL.csv\") #note, should skip the \"header\" lines, i took them out manually"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"data['Type'].unique()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"#these are transactions that are \"authorization\" and duplicates for debit card use\n",
"cleaner_data = data[~((data['Type'] == 'Payment Authorized') | (\n",
" data['Type'] == 'Transfer to Bank Initiated') | (\n",
" data['Type'] == 'PP Debit Card Authorization') | (\n",
" data['Type'] == 'Authorized Funds Held') | (\n",
" data['Type'] == 'Funds Released'))].copy()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"name_nulls = cleaner_data['Name'].isnull()\n",
"\n",
"cleaner_data.loc[name_nulls, 'Name'] = cleaner_data[name_nulls]['Subject'] # if Name is not present use Subject"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"name_nulls = cleaner_data['Name'].isnull()\n",
"\n",
"\n",
"cleaner_data.loc[name_nulls, 'Name'] = cleaner_data[name_nulls]['Type'] #if Name still not present use type"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"cleaner_data.to_csv(\"Downloads/DHR_clean.csv\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment