Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.1 kB
7
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/Documents/New folder/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/apskaita3/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)







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


   

df3=df2.append(df,ignore_index=True)
df3 = df3[~df3.index.duplicated()]
#df3= df.sort_values(by=['Execution Time']
#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/apskaita3/Desktop/Nasdaq_file/share_export.csv', index=False)
#df3.reset_index(drop=True, inplace=True)