By the numbers...

Friday, September 18, 2015

How to read command line output directly into pandas dataframe?

cmd = r"zgrep abc application.log | perl -pe 's/pattern/subs/'"
# python 2
pd.read_csv(StringIO.StringIO(subprocess.check_output(cmd, shell=True)))
# python 3
pd.read_csv(BytesIO(subprocess.check_output(cmd, shell=True)))
Posted by linkedin.com/in/maxtang at 1:09 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: python
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ►  2022 (1)
    • ►  December (1)
  • ►  2020 (5)
    • ►  November (1)
    • ►  October (1)
    • ►  June (1)
    • ►  April (1)
    • ►  March (1)
  • ►  2019 (4)
    • ►  December (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (1)
  • ►  2018 (1)
    • ►  December (1)
  • ►  2017 (2)
    • ►  March (2)
  • ►  2016 (9)
    • ►  November (2)
    • ►  October (1)
    • ►  September (1)
    • ►  August (1)
    • ►  July (1)
    • ►  June (1)
    • ►  February (1)
    • ►  January (1)
  • ▼  2015 (19)
    • ►  December (2)
    • ►  November (3)
    • ►  October (1)
    • ▼  September (1)
      • How to read command line output directly into pand...
    • ►  August (2)
    • ►  July (1)
    • ►  May (4)
    • ►  March (3)
    • ►  January (2)
  • ►  2014 (43)
    • ►  December (16)
    • ►  November (1)
    • ►  September (2)
    • ►  August (3)
    • ►  July (2)
    • ►  May (4)
    • ►  April (3)
    • ►  March (7)
    • ►  February (1)
    • ►  January (4)
  • ►  2013 (1)
    • ►  December (1)

About Me

My photo
linkedin.com/in/maxtang
View my complete profile
Awesome Inc. theme. Powered by Blogger.