Python Forum
Unable to Validate csv blanck data and write in csv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to Validate csv blanck data and write in csv
#1
Hi Support,
I have one csv file and some field is blank. now i m writing code to read csv file and if filed is blank then take the input from the user and write in csv.

CSV Format:
Output:
AccountId RegionName SubnetID OS_Name KeyName eastus demo_subnet server2012 window_keyname
import csv
reader = csv.DictReader(open("D:\python_Step_Step_Lab\Book1.csv"))
for raw in reader:
    print(raw)
    test=(raw['AccountId'])
    test01=(raw['RegionName'])
    test02=(raw['SubnetID'])
    test03=(raw['OS_Name'])
    test04=(raw['KeyName'])
   
    if test == '':
        print("Enter the AccountId: " ) # Required input from user and store in csv

    elif test01='':
        print("Enter the RegionName: ") # Required input from user and store in csv

    elif test02='':
        print("Enter the Subnet ID: ") # Required input from user and store in csv

    elif test03='':
        print("Enter the OS_Name: ") # Required input from user and store in csv

    elif test04='':
        print("Enter the KeyName: ") # Required input from user and store in csv
   
    else:
        print("All parameter is Correct")

            with open("D:\python_Step_Step_Lab\Book1.csv", 'w') as csvfile:      # Store the input in same file Book1.csv
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  validate large json file with millions of records in batches herobpv 3 1,263 Dec-10-2022, 10:36 PM
Last Post: bowlofred
  Create SQL connection function and validate mg24 1 937 Sep-30-2022, 07:45 PM
Last Post: deanhystad
  Write sql data or CSV Data into parquet file mg24 2 2,419 Sep-26-2022, 08:21 AM
Last Post: ibreeden
Sad how to validate user input from database johnconar 3 1,910 Sep-11-2022, 12:36 PM
Last Post: ndc85430
  Unable to request image from FORM Data usman 0 990 Aug-18-2022, 06:23 PM
Last Post: usman
  Is this possible to write a script for checking data from website? WanW 2 1,115 Jun-02-2022, 02:31 AM
Last Post: Larz60+
  Write and read back data Aggie64 6 1,863 Apr-18-2022, 03:23 PM
Last Post: bowlofred
Lightbulb [Solved] df.loc: write data in certain rows ju21878436312 1 1,700 Jun-28-2021, 06:49 AM
Last Post: ju21878436312
  unable to write to log file Mekala 2 2,066 Aug-12-2020, 11:02 PM
Last Post: Mekala
  Validate JSON file BellaMac 12 5,338 Feb-27-2020, 03:17 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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