1. generate folders from list 2. copy excel sheet 3....

41

Upload: others

Post on 25-Jun-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 2: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 3: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

1. GENERATE FOLDERS FROM LIST

2. COPY EXCEL SHEET

3. EXTRACTING DATA FROM LAS FILES

4. CONTROLLING MOUSE & KEYBOARD

5. DIGITIZE OLD LOGS

Page 4: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

PRACTICAL SCRIPTING IDEAS FOR DATA MANAGERS WITH PYTHON

Alvin Alexander

Geotechnician

JX Nippon Oil & Gas Exploration

Page 5: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Why Automate?

1. Menial tasks are boring.

2. HSE concern. Wrist Pain.

3. Minimize mistakes.

4. Time Saving in the long run.

5. Writing code is fun and creative.

Page 6: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

WHEN TO AUTOMATE?Real Examples

Page 7: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 8: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

1. GENERATE FOLDERS FROM LIST

2. COPY EXCEL SHEET

3. EXTRACTING DATA FROM LAS FILES

4. CONTROLLING MOUSE & KEYBOARD

5. DIGITIZE OLD LOGS

Incr

easi

ng

Co

mp

lexi

ty

Page 9: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

1

Page 10: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 11: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

1. Open List

2. Copy one item

3. Create Folder

4. Rename and paste

5. Repeat 2 to 4 until finish

Before Automation

Page 12: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Python Script Automation

The list

The 5 linesof code

Generatedfolders

Page 13: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

2

Page 14: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 15: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

1. Create Destination Excel

2. Open Origin Excel

3. Copy target cells

4. Paste into Destination

5. Close Origin Excel

6. Repeat 2 – 5

Before Automation

Page 16: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Python Script Automation

Page 17: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

3

Page 18: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 19: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Manual Extract Data From LAS

1. Open LAS using text editor

2. Paste to excel

3. Copy one column

4. Paste into another excel

5. Repeat for all files

…or you can use some software that can read LAS files

Before Automation

Page 20: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Python Script Automation

Essentially the code do the following,

1. Look for the “~Ascii” keyword

2. Copy data as table into intermediary format

3. Copy data only at specific depth zones

4. Save data table as desired format

Page 21: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Method to look for keyword

Method to copy data

Method to copy specific depth zones

Page 22: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

4

Page 23: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Manual Mouse Movement

1. Movement of mouse depends solely on our hands which is often less than perfect and irregular.

Before Automation

Page 24: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Python Script AutomationPerfect square

Perfect square

Page 25: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Python Script AutomationPerfect square

Perfect spiral

Page 26: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Python Script AutomationPerfect square

Perfect sine wave

Hand drawn sine wave

Page 27: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

5

Page 28: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 29: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Manually Digitize old Logs

1. Load image into software with

2. Draw to follow the lines as seen on screen

Before Automation

Page 30: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Python Script Automation

Page 31: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Essentially,

1. The script automatically detects the black as data

2. Calculate against the width of the image to determine the value

3. Calculate against the length of the image to determine the depth

Python Script Automation

Page 32: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Bonus Example

Page 33: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Bonus

Page 34: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Batch File Automation

Page 35: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Friendly Tools

Anaconda Python Distribution

Help you manage data science packages for Python

For Python it’s like

Android’s “Play Store”

Apple’s “App Store”

Page 36: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 37: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Friendly Tools

Jupyter Notebook

Full IDE is usually hard to learn while coding using text file is too tedious

Notebook Cells

• it is so much easy to edit & run specific lines of codes using Notebook cells.

Page 38: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 39: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Final Tips

Scripts should never not be general purpose

Write simple first, then combine

Writing scripts is fun, try it!

Page 40: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat
Page 41: 1. GENERATE FOLDERS FROM LIST 2. COPY EXCEL SHEET 3. …3b3088bd9c47f407a4d2-5a46b125adfc01d909dffba6766a3f2c.r32.c… · 3. Copy one column 4. Paste into another excel 5. Repeat

Thank you!You can have all the codes here.

My Contact Info

Email: [email protected]