Quick Python 6: Our First Data Pipeline

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ย. 2024

ความคิดเห็น • 8

  • @charlesakwasiopoku7656
    @charlesakwasiopoku7656 3 ปีที่แล้ว +5

    Great. A simple overview of data pipeline.

  • @DanielFanfanfan
    @DanielFanfanfan 3 ปีที่แล้ว +1

    Well explained!

  • @brandonbirmingham3868
    @brandonbirmingham3868 3 ปีที่แล้ว +1

    Couldn't that possibly crash with data overload if you use that short cut than you would just have to add a check for that no?

    • @PageKey
      @PageKey  2 ปีที่แล้ว

      This is a really great point! Not checking to make sure the data is in the right format is dangerous in general and could leave the program (and in turn, your computer) open to cyber vulnerabilities. In real world programming we should always validate our inputs, ESPECIALLY if the data comes from the user (or anywhere we don't directly control).

  • @enosie
    @enosie 3 ปีที่แล้ว +2

    nice

  • @MxSlfDstrct
    @MxSlfDstrct 2 ปีที่แล้ว

    great tutorial! is there a way to stop reading from stdin if no data is piped to the script?
    edit: after some google-fu, I was actually able to figure out some code that elegantly handles input both from pipes and normal passed arguments - see below.
    # Exclude the first argument in passed_arguments,
    # because it's always just the script's name.
    passed_arguments = sys.argv[1:]
    # Checks if anything has been piped in by seeing if stdin is interactive (ie,
    # expecting input from keyboard). If *not*, process it and add it to the list of
    # arguments. If it *is*, ignore it.
    if sys.stdin.isatty() == False:
    piped_input = sys.stdin.readline().strip().split(" ")
    arguments = passed_arguments + piped_input
    else:
    arguments = passed_arguments
    this was tested on Linux. it almost certainly also works on Mac OS, and will probably work on Windows too.

    • @PageKey
      @PageKey  2 ปีที่แล้ว +1

      Good question! I think that the for loop will not execute if there are no lines available in stdin when you pipe to it. There are also ways to detect and skip if the program is called without piping anything in. Check this answer out for more info on that: stackoverflow.com/questions/3762881/how-do-i-check-if-stdin-has-some-data

    • @PageKey
      @PageKey  2 ปีที่แล้ว +1

      Awesome!! Great solution!