Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
4.0 kB
12
Indexable
Never
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import csv
import time
import glob
import os
import pandas as pd
import re, os.path

from pathlib import Path

  
# Open Chrome


#options=webdriver.ChromeOptions();

#prefs={"download.default_directory":"C:/DumpStack.log.tmpUsers/apskaita3/Desktop/Nasdaq_file"}

#options.add_experimental_option("prefs",prefs)


driver = webdriver.Chrome("C:/Users/Žymantas/Desktop/Nasdaq_file/chromedriver.exe")
driver.minimize_window()
#driver.set_window_size(-10000000,-1000000000)
# Open URL
driver.get(
    'http://www.nasdaqomxnordic.com/aktier/microsite?Instrument=VSE28424&name=Apranga&ISIN=LT0000102337')
  
# Enter text
#driver.find_element_by_id('textbox').send_keys("Hello world")
  
# Generate Text File
#driver.find_element_by_id('createTxt').click()
  
# Click on Download Button
driver.find_element_by_id('exportIntradayTradesCSV').click()

time.sleep(5)

driver.close()


#with open('C:/Users/apskaita3/Downloads/share_export.csv', mode ='r') as file:
   
 # csvFile = csv.reader(file)
 
  #for lines in csvFile:
   #   print(lines)

#all_files = glob.glob('C:/Users/apskaita3/Downloads/share_export.csv') #give path to your desired file path
#latest_csv = max(all_files, key=os.path.getctime)
#print(latest_csv)


folder_path = r'C:/Users/Žymantas/Downloads'
file_type = '\*csv'
files = glob.glob(folder_path + file_type)
max_file = max(files, key=os.path.getctime)

#df = pd.read_csv(max_file,  sep=';',skiprows=1)
#print(df)



df0=pd.read_csv('C:/Users/Žymantas/Downloads/share_export.csv',  sep=';',skiprows=1)


df2= pd.read_csv('C:/Users/Žymantas/Desktop/Nasdaq_file/share_export.csv',sep=';',skiprows=1)        
#print(df2)

#df2_1= pd.read_csv('C:/Users/Žymantas/Desktop/Nasdaq_file/share_export.csv',sep=';',skiprows=1)
#f2_2= pd.read_csv('C:/Users/Žymantas/Desktop/Nasdaq_file/share_export.csv',sep=';',skiprows=1)  

df3=df2.append(df0, ignore_index=True)
#df3 = df0.append(df2_1, ignore_index=True).append(df2_2, ignore_index=True)
#df3=df2.append(df0,ignore_index=True)
#df3 = df3[~df3.index.duplicated()]
df3= df3.sort_values(by=['Execution Time'])
print(df3.tail())
#df3.columns = df3.columns.str.replace(' ', '')
#print(df3.columns)
#print(df3.iloc[:, 1])
#df3.sort_values(by=['Execution Time'], inplace=True, ascending=False)
#print(df3.columns.tolist())
df3.to_csv('C:/Users/Žymantas/Desktop/Nasdaq_file/share_export.csv', index=False)
#df3.reset_index(drop=True, inplace=True)

#df=pd.read_csv('C:/Users/apskaita3/Downloads/f1.csv',index_col=0)
#a=df.to_csv('C:/Users/apskaita3/Desktop/Nasdaq_file/share_export.csv')
#b=pd.read_csv(io.StringIO(a.to_csv(index=False)))
#df.to_csv('C:/Users/apskaita3/Desktop/Nasdaq_file/share_export.csv')
#df.to_csv('C:/Users/apskaita3/Desktop/Nasdaq_file/share_export.csv', mode='a', index=False, header=False)






#print(df)


#with open(max_file, 'r') as file:
#    reader = csv.reader(file)


#file.close()






#path='C:/Users/apskaita3/Desktop/Nasdaq_file/'+ max_file





#df = pd.read_csv(max_file,sep=';')
#df.to_csv('C:/Users/apskaita3/Desktop/Nasdaq_file/share_export.csv')
#file = open(max_file)
#csvreader = csv.reader(file)


#header = []
#header = next(csvreader)
#header

#rows = []
#for row in csvreader:
#        rows.append(row)
#rows


#pattern = "share_export"
#mypath = "C:/Users/apskaita3/Downloads"
#for root, dirs, files in os.walk(mypath):
  #  for file in filter(lambda x: re.match(pattern, x), files):
  #      os.remove(os.path.join(root, file))


#df2 = pd.read_csv('C:/Users/apskaita3/Desktop/Nasdaq_file/share_export.csv')


#modTimesinceEpoc = os.path.getmtime('C:/Users/apskaita3/Downloads/share_export(13).csv')
# Convert seconds since epoch to readable timestamp
#modificationTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(modTimesinceEpoc))
#print("Last Modified Time : ", modificationTime )