Python Forum
Need some coding guidance for a task
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some coding guidance for a task
#1
I am not that good in scripting (I have worked before in python) but I would like to give a try, since I need to create a script to automatize my process. Therefore, I would really appreciate it if someone could give me some help, by offering some guidance on how I could do it. The script I would like to create has 2 phases:
1) will ask from the user to answer specific questions (filling the metadata) and it will save the questions and the answers to a file (word or excel).
2) One of the questions for the user, will be to give the path where the spatial data are located, from which I would like to read them, create their circumference (polygon) and store it in a file (either GeoTIFF, xyz, GeoJSON or other geoformat).
Thanks in advance!
Reply
#2
Hi Peny, welcome to the forum. We will help you, but first you must try yourself. It is good you split the problem in parts. We expect you to show some code and tell us what goes wrong. Then we will guide you.
So best is to show what you made of the first part. Must it be Word or Excel? Better to try first with a text file.
Reply
#3
Hello,

Basic input/save is this:

#Import the required modules
import csv
from csv import reader

# Take in the data

x = input("Question 1: ")

#Read the data already in the csv, if you dont do this, the program will overwrite the file with just the current line.

with open('mycsv.csv','r') as data:
    data_read = reader(data)
    for row in data_read:
    mylist.append(row)

#Then add your new answer to the list
mylist.append(x)

#Then we write the data to the csv, this will keep all the old data, and add the new input at the bottom. Or the right, I forget, the point is, its in another cell

with open('mycsv.csv',w',newline='') as total_data:
    csvWriter = csv.writer(total_data,delimiter = ',')
    for x in range(len(mylist)):
    csvWriter.writerow(mylist[x])
while dad_has_cigs == True:
    happiness = True
    if dad_has_cigs == False:
    print("Dad come home!")
    happiness = not happiness
    break
Reply
#4
Thank you jamesaarr !

Some of what you wrote, I have already used them in the script I tried to create. But I miss a lot and that is really helpful!
I will try to adjust it and see if it works.

Do you might have any idea on how I could create the polygon of spatial data?
They are in a csv format and they are georeferenced (contain coordinates).
Reply
#5
Hello peny,

Not a clue, I'd need examples of the data, and an example of the output you're after.

Thanks,
James
while dad_has_cigs == True:
    happiness = True
    if dad_has_cigs == False:
    print("Dad come home!")
    happiness = not happiness
    break
Reply
#6
It doesn't matter you already helped me enough!
I will try a few things, otherwise I will do in another program.
Thanks again!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  count certain task in task manager[solved] kucingkembar 2 1,116 Aug-29-2022, 05:57 PM
Last Post: kucingkembar
  Schedule a task and render/ use the result of the task in any given time klllmmm 2 2,081 May-04-2021, 10:17 AM
Last Post: klllmmm
  Your Guidance caslor 1 2,128 Mar-28-2021, 09:34 PM
Last Post: Larz60+
  How to create a task/import a task(task scheduler) using python Tyrel 7 3,702 Feb-11-2021, 11:45 AM
Last Post: Tyrel
  Noob needing guidance.... bako 0 1,852 Mar-29-2020, 06:55 PM
Last Post: bako
  General Guidance in Project JMiller184 1 3,022 Oct-24-2017, 10:27 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020