Skip to content

Instantly share code, notes, and snippets.

View smram's full-sized avatar

Smriti Ramakrishnan smram

View GitHub Profile
Q: How to paste tab-separated data into Google Sheets
Problem: Google sheets automatically parses CSV data into columns on paste. It doesn't work with TSV - cannot detect tab as a separator automatically, and I cannot figure out how to enter tab as a custom separator.
Solution:
1. Data -> Cleanup Data -> Trim whitespace.
2. Data -> Split text into columns -> Choose space as the separator
# osx
/usr/bin/time -l `ls`
# linux
/usr/bin/time -v `ls`
# from here: https://stackoverflow.com/questions/774556/peak-memory-usage-of-a-linux-unix-process
@smram
smram / pandas_newline_strip.txt
Created October 4, 2017 23:35
[pandas] replace newlines,tabs,carriage returns in fields
# got to handle both escaped and literal
df.replace(to_replace=[r"\\t|\\n|\\r", "\t|\n|\r"], value=["",""], regex=True, inplace=<INPLACE>)