Tuesday, August 30, 2022

How to list all files in the folder and sub folder ( directories and sub directories) and store it in csv files

 Hi Everyone,

I am newbie to Python #python 

I have tried so many sites and could not able to find how to get files from the folder and its sub folder.

So i got bit and pieces from stakeoverflow forum and created this code with help of my friend Gowrishankar.

Please find the code below

code:-

import os
import pandas as pd
#path of the file you want to enemurate
path = "//home//halovivek//Downloads//education//Jimi Kwik - Super Brain//"
directory =[]
filename=[]

for (root,dirs, file) in os.walk(path):
for f in file:
directory.append(root)
filename.append(f)

print(f)

#column name of the sheet
df=pd.DataFrame(list(zip(directory,filename)),columns=['Directory',"filename"])
#change the file of exccl sheet
df.to_csv("filedirectory.csv")

 (path:- if you are using windows then you need to use backward slash (\\)  instead of forward slash - // )

Output:-

/home/halovivek/PycharmProjects/yearcoding/venv/bin/python /home/halovivek/PycharmProjects/yearcoding/30082022_listfilesfromdirectory.py
Day 12 - Implementation Day - Juggling Exercise.mp4
Day 12 - Implementation Day - Juggling Exercise.MP3
Part 2 - Preparing For The Quest.mp4
Part 1 - Welcome To Your 30-Day Superbrain Quest.mp4
Part 5 - 10 Morning Habits Geniuses Use To Jump Start The Brain.mp4
Part 3 - The FAST Method For Learning Anything.mp4
Part 2 - Preparing For The Quest.MP3
Part 1 - Welcome To Your 30-Day Superbrain Quest.MP3
Part 5 - 10 Morning Habits Geniuses Use To Jump Start The Brain.MP3
Part 4 - How To Take Notes.mp4
Part 3 - The FAST Method For Learning Anything.MP3
Part 4 - How To Take Notes.MP3
Day 27 - The Ancient Alphanumeric Code Of Memory Part 2 - Application.MP3
Day 27 - The Ancient Alphanumeric Code Of Memory Part 2 - Application.mp4
Day 29 - The 5 Levels Of Transformation.MP3
Day 29 - The 5 Levels Of Transformation.mp4
Day 14 - Memory Is As Easy As PIE.MP3
Day 14 - Memory Is As Easy As PIE.mp4
Day 15 - The FDR Technique.MP3
Day 15 - The FDR Technique.mp4
Day 31 - Overcoming Procrastination.mp4
Day 31 - Overcoming Procrastination.MP3
Day 9 - Chain Linking - Part 1.mp4
Day 9 - Chain Linking - Part 1.MP3
Day 8 - Implementation Day - Morning Routine.mp4
Day 8 - Implementation Day - Morning Routine.MP3
Day 24 - Implementation Day - Crossovers.MP3
Day 24 - Implementation Day - Crossovers.mp4
Day 19 - Learning Foreign Languages.mp4
Day 19 - Learning Foreign Languages.MP3
Day 13 - BE SUAVE Remembering Names.MP3
Day 13 - BE SUAVE Remembering Names.mp4
Day 34 - Speed Reading.MP3
Day 34 - Speed Reading.mp4
Day 22 - The Location Method.MP3
Day 22 - The Location Method.mp4
Day 5 - Nutrition _ Your Body Folders.MP3
Day 5 - Nutrition _ Your Body Folders.mp4
Day 23 - Memorize Word For Word.MP3
Day 23 - Memorize Word For Word.mp4
Day 30 - Q&A Session with Jim.mp4
Day 30 - The 5 Levels Of Learning.mp4
Day 30 - The 5 Levels Of Learning.MP3
Day 30 - Q&A with Jim.MP3
Day 28 - Implementation Day - Phonetic Number Code.MP3
Day 28 - Implementation Day - Phonetic Number Code.mp4
How To Become A Super Learner Masterclass - Jim Kwik.mp4
how_to_become_a_super_learner_by_jim_kwik_workbook_nsp.pdf
Day 18 - Keyword Substitution Method.MP3
Day 18 - Keyword Substitution Method.mp4
Day 32 - Your 8 C's To Muscle Memory.mp4
Day 32 - Your 8 C's To Muscle Memory.MP3
Day 4 - Implementation Day - Spaced Repetition Concept.mp4
Day 4 - Implementation Day - Spaced Repetition Concept.MP3
Day 26 - The Ancient Alphanumeric Code Of Memory Part 1 - The Sounds.MP3
Day 26 - The Ancient Alphanumeric Code Of Memory Part 1 - The Sounds.mp4
Day 2 - The Sun Is Up.mp4
Day 2 - The Sun Is Up.MP3
Day 16 - Implementation Day - Superbrain Yoga.MP3
Day 16 - Implementation Day - Superbrain Yoga.mp4
Day 10 - Chain Linking - Part 2.MP3
Day 10 - Chain Linking - Part 2.mp4
.getxfer.14810.259.mega
Day 7 - Sleep _ Stress Management.MP3
Day 7 - Sleep _ Stress Management.mp4
Day 33 - Remembering Your Dreams.mp4
Day 33 - Remembering Your Dreams.MP3
.getxfer.14709.10.mega
.getxfer.28947.5.mega
Day 21 - How To Give A Speech Without Notes.MP3
.getxfer.27388.5.mega
Day 3 - The 10 Keys To Unlocking Your Superbrain.mp4
.getxfer.10040.5.mega
Day 6 - Environments _ Killing ANTs.MP3
_Groupinsiders.com.url
Day 6 - Environments _ Killing ANTs.mp4
Day 25 - Numbers - The Basics.mp4
Day 25 - Numbers - The Basics.MP3
Day 1 - M.O.M. Can Help You Remember.MP3
Day 1 - M.O.M. Can Help You Remember.mp4
Day 20 - Implementation Day - Counting To 10 In Japanese.MP3
Day 20 - Implementation Day - Counting To 10 In Japanese.mp4
Day 11 - The Peg Memory Method.MP3
Day 11 - The Peg Memory Method.mp4
Day 17 - The Ultimate TIP To Remembering Anything.MP3
Day 17 - The Ultimate TIP To Remembering Anything.mp4

Process finished with exit code 0


Sunday, February 20, 2022

Drag and Drop - Selenium with python

 Hi

I am studying the drag and drop using Selenium with python

Below the code. thanks to everyone

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

driver = webdriver.Firefox()
driver.maximize_window()
driver.get('http://www.dhtmlgoodies.com/scripts/drag-drop-custom/demo-drag-drop-3.html')
time.sleep(5)
driver.get("http://www.dhtmlgoodies.com/scripts/drag-drop-custom/demo-drag-drop-3.html")
drag = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[starts-with(@id, 'box') and text()='Rome']")))
drop = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[starts-with(@id, 'box') and text()='South Korea']")))
ActionChains(driver).drag_and_drop(drag, drop).perform()


'''drg = driver.find_element(By.XPATH, "//*[@id='dropContent']//div[@class='dragableBox' and @id='box5']")
drp = driver.find_element(By.XPATH, "//*[@id='countries']//div[@class='dragableBoxRight' and @id='box105']")
ActionChains(driver).drag_and_drop(drg, drp).perform()
time.sleep(5)'''
#driver.quit()

Wednesday, February 9, 2022

Going to write about Selenium with Python

 Hi All,

From yesterday I have started to learn about the Selenium with Python.

I am going to write down the blog and step by step methods.

I am going to spend each one hour on learning the selenium with python.

I will update all the tips and tricks which i followed and found out.

I hope I will update the blog without fail.

Thanks


How to Get files from the directory - One more method

 import os import openpyxl # Specify the target folder folder_path = "C:/Your/Target/Folder"  # Replace with the actual path # Cre...