Skip to content

Instantly share code, notes, and snippets.

@bobquest33
bobquest33 / IFCB2009_19_modified.csv
Created March 17, 2017 08:34
cutplace CVS Excel Demo
bank ifsc_code micr_code branch_name address contact city district state
CHINATRUST COMMERCIAL BANK CTCB0000001 110036251 NEW DELHI BRANCH 604, 6TH FLOOR MERCANTILE HOUSE, 15, K.G. MARG, NEW DELHI - 110001 MR. PRABHAKAR NEW DELHI NEW DELHI DELHI
import os
import glob
import sys
import cutplace
import cutplace.errors
cid_path = sys.argv[1]
format = sys.argv[2]
print format
csvfiles = glob.glob(format)
C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv/IFC*modified.csv
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_01_modified.csv
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_02_modified.csv
IFCB2009_02_modified.csv (R47C6): cannot accept field 'contact': value must not be empty
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_03_modified.csv
IFCB2009_03_modified.csv (R1067C6): cannot accept field 'contact': value must not be empty
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_04_modified.csv
IFCB2009_04_modified.csv (R170C6): cannot accept field 'contact': value must not be empty
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_05_modified.csv
IFCB2009_05_modified.csv (R2C3): cannot accept field 'micr_code': value must not be empty
@bobquest33
bobquest33 / cid_ifc1.csv
Created March 17, 2017 09:26
cutplace csv validation demo
Interface: IFC
Data format
D Format CSV
D Header 1
Fields
Name Example Empty Length Type Rule
C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv/IFC*modified.csv
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_01_modified.csv
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_02_modified.csv
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_03_modified.csv
IFCB2009_03_modified.csv (R2C2): cannot accept field 'ifsc_code': length of 'ifsc_code' with value '\xa0ALLA0211956\xa0\xa0\xa0\xa0\xa0\xa0\xa0' is 19 but must be within range: 11
Validating:C:/Users/IBM_ADMIN/Documents/php_jquery-ajax/csv\IFCB2009_04_modified.csv
IFCB2009_04_modified.csv (R625C3): cannot accept field 'micr_code': length of 'micr_code' with value 'PARADEEP PORT' is 13 but must be within range: 0...9
@bobquest33
bobquest33 / eliza_botdemo.py
Created March 22, 2017 09:46
Eliza chatbot example code
# Natural Language Toolkit: Eliza
#
# Copyright (C) 2001-2017 NLTK Project
# Authors: Steven Bird <[email protected]>
# Edward Loper <[email protected]>
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
# Based on an Eliza implementation by Joe Strout <[email protected]>,
# Jeff Epler <[email protected]> and Jez Higgins <mailto:[email protected]>.
@bobquest33
bobquest33 / chattranscript.log
Created March 22, 2017 09:49
Eliza Chatbot Demo
# Ran the below code from commandline
>python eliza_botdemo.py
Therapist
---------
Talk to the program by typing in plain English, using normal upper-
and lower-case letters and punctuation. Enter "quit" when done.
========================================================================
Hello. How are you feeling today?
>am good
I see. And what does that tell you?
@bobquest33
bobquest33 / extract_emails_from_text.py
Created March 23, 2017 10:07 — forked from dideler/example.md
A python script for extracting email addresses from text files. You can pass it multiple files. It prints the email addresses to stdout, one address per line. For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <[email protected]>
@bobquest33
bobquest33 / csv_import.py
Created April 5, 2017 21:10
Importing data from CSV
import csv
import sys
filename = 'ch02-data.csv'
data = []
try:
with open(filename) as f:
reader = csv.reader(f)
header = next(reader)
data = [row for row in reader]
except csv.Error as e:
@bobquest33
bobquest33 / xls_load.py
Created April 5, 2017 21:16
Importing data from Microsoft Excels
import xlrd
from pprint import pprint
file = 'ch02-xlsxdata.xlsx'
wb = xlrd.open_workbook(filename=file)
ws = wb.sheet_by_name('Sheet1')
dataset = []
for r in range(ws.nrows):
col = []
for c in range(ws.ncols):
col.append(ws.cell(r, c).value)