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
import operator
from pathlib import Path
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import numpy as np
#ser = Service("C:/Users/apskaita3/Documents/New folder/chromedriver.exe")
#options = webdriver.ChromeOptions()
#prefs = {'download.default_directory' : 'C:/Users/apskaita3/Desktop/Nasdaq_file/companies'}
#prefs = {"profile.default_content_settings.popups": 0"download.default_directory": r"C:/Users/apskaita3/Desktop/Nasdaq_file/companies/""directory_upgrade": True} # IMPORTANT - ENDING SLASH V IMPORTANT
#options.add_argument('--headless')
#options.add_experimental_option('prefs' prefs)
#driver = webdriver.Chrome(service=ser)
driver = webdriver.Chrome("C:/Users/Žymantas/Desktop/Nasdaq_file/chromedriver.exe")
driver.minimize_window()
driver.get('http://www.nasdaqomxnordic.com/aktier/microsite?Instrument=VSE95425&name=Amber%20Grid&ISIN=LT0000128696')
#l=driver.find_element_by_css_selector("h1")
#name=l.text
driver.find_element_by_id('exportIntradayTradesCSV').click()
time.sleep(3)
driver.close()
try:
old_csv = pd.read_csv('C:/Users/Žymantas/Downloads/share_export - 2022-01-29T180712.824.csv',sep=';',skiprows=1)
except pd.errors.EmptyDataError:
#old_csv14 = pd.DataFrame()
old_csv = pd.DataFrame(columns=['Execution Time', 'Execution Time UTC', 'ISIN', 'Publication Time','Publication Time UTC','CCY','Venue of execution (MIC Code)', 'Venue of publication (MIC Code)','Price notation','Transaction to be cleared','MMT Flags','Transaction ID Code', 'Price', 'Volume', 'Buyer', 'Seller', 'Trade type'])
#old_csv = pd.read_csv('C:/Users/apskaita3/Downloads/share_export.csv',sep=';',skiprows=1)
new_csv = pd.read_csv('C:/Users/Žymantas/Desktop/Nasdaq_file/Nasdaq_tradings/apranga.csv',sep=';')
if ('sep=' in new_csv.columns.tolist()):
new_csv = pd.read_csv('C:/Users/Žymantas/Desktop/Nasdaq_file/Nasdaq_tradings/apranga.csv',sep=';',skiprows=1)
print(6)
print(new_csv)
else:
new_csv = pd.read_csv('C:/Users/Žymantas/Desktop/Nasdaq_file/Nasdaq_tradings/apranga.csv',sep=',')
print(5)
print(old_csv)
new_df14 = pd.concat([old_csv, new_csv]).reset_index(drop=True)
#old_csv.columns = new_csv.columns
new_df14.columns = old_csv.columns
new_df14=new_df14.sort_values('Execution Time', ascending = False).drop_duplicates()
new_df14.to_csv('C:/Users/Žymantas/Desktop/Nasdaq_file/Nasdaq_tradings/apranga.csv',index = False)