Python Forum
Pulling & Reading Date from UDF that Compare it to Live Data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pulling & Reading Date from UDF that Compare it to Live Data
#1
Hello Everyone!
Would you help me solve the following problem i have:
I am trying to write a user defined function that would load, read date from a csv file, itereate through the column where row of values being examined are located, check those values against current value (price = live.get_live_price("AAPL"))and then take an action (in this case to print it out) if the comparison meet certain condition (row value < price or row == price). when i run the script i do not get any error message and yet there is no output at all.
Thank you
#import all necessary modules
import csv
from yahoo_fin import stock_info as live
import pandas as pd
from datetime import date
import datetime


def readfile(filepath):
    #get Apple's latest quote price
    price = live.get_live_price("AAPL")

    with open(r'C:\Users\...\Desktop\AAPLCSV', 'r') as file:
        reader = csv.reader(file)
        for index, row in reader:
            if row[3] < price:
                return price
            elif row[3] == price:
                return row[3]
            print(price, row[3])
Reply


Messages In This Thread
Pulling & Reading Date from UDF that Compare it to Live Data - by firebird - Jul-19-2019, 07:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 251 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 623 Jan-20-2024, 04:45 AM
Last Post: 1418
  Pulling Specifics Words/Numbers from String bigpapa 2 773 May-01-2023, 07:22 PM
Last Post: bigpapa
  Having trouble installing scikit-learn via VSC and pulling my hair out pythonturtle 1 767 Feb-07-2023, 02:23 AM
Last Post: Larz60+
  Create simple live plot of stock data dram 2 2,937 Jan-27-2023, 04:34 AM
Last Post: CucumberNox
  (Python) Pulling data from UA Google Analytics with more than 100k rows into csv. Stockers 0 1,241 Dec-19-2022, 11:11 PM
Last Post: Stockers
  Reading All The RAW Data Inside a PDF NBAComputerMan 4 1,358 Nov-30-2022, 10:54 PM
Last Post: Larz60+
  Pulling username from Tuple pajd 21 3,432 Oct-07-2022, 01:33 PM
Last Post: pajd
  Reading Data from JSON tpolim008 2 1,097 Sep-27-2022, 06:34 PM
Last Post: Larz60+
  How can I compare 2 format of date? korenron 4 1,535 Dec-21-2021, 12:40 PM
Last Post: korenron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020