Home > Blockchain >  Dataframe to csv, how to skip lines in csv file
Dataframe to csv, how to skip lines in csv file

Time:10-25

I was working on my project pandas data frame to csv file. The rows are created based on the input this is what I mean :3 so the issue is that the 1st rows keeps on changing as I loop the script the results :3. Also need help for looping the script

from ast import Break
import pandas as pd
import socket
import webbrowser,time

def introduction():
    msg = '''
         This is a python project made by Abhay R 
         of ************************************.
      
         This project is based on how internet 
          service providers collect 
          data from clients\n\n\n\n\n'''
    for x in msg:
         print(x, end='')
         time.sleep(0.002)
          wait = input('Press any key to continue.....')

introduction()
print()
  
def begin():
      url=input("ENTER YOUR WEB HERE:")
      web=webbrowser.open_new_tab(url) 


      weblink = url


      Domain_name = ""


      x = weblink.split("/")



      if(x[0] == "https:" or x[0] == "http:"):

             x = x[2].split(".")



      else:

             x = x[0].split(".")


     if(len(x) == 2):

             Domain_name = x[0]


     else:

             Domain_name = x[1]

     print("Domain Name Is:",Domain_name)        

     dns=socket.gethostbyname(weblink)
     print("DNS:",dns)


     domain=Domain_name
     dns=dns
     data={"WEBSITE":weblink,"DOMAIN":domain,"DNS":dns}
     df1=pd.DataFrame(data,index=[1])
     df1.to_csv("C:\\Users\\stdev\\Desktop\\IP PROJECT\\Book 9.csv")



     cvv=pd.read_csv("C:\\Users\\stdev\\Desktop\\IP PROJECT\\Book 9.csv")
     print(cvv)

     begin()

Hope my question is understandable and anyone can help me with this soon as possible.

CodePudding user response:

The issue have been solved thankyou @furas

import pandas as pd
import socket
import webbrowser,time

def introduction():
      msg = '''
           This is a python project made by Abhay R 
           of ************************************.
      
           This project is based on how internet service providers collect 
           data from clients\n\n\n\n\n'''
      for x in msg:
          print(x, end='')
          time.sleep(0.002)
          wait = input('Press any key to continue.....')

introduction()
print()

def begin():
    url=input("ENTER YOUR WEB HERE:")
    web=webbrowser.open_new_tab(url) 


    weblink = url


    Domain_name = ""


    x = weblink.split("/")



    if(x[0] == "https:" or x[0] == "http:"):

          x = x[2].split(".")



    else:

          x = x[0].split(".")


    if(len(x) == 2):

          Domain_name = x[0]


    else:

          Domain_name = x[1]

    print("Domain Name Is:",Domain_name)        

    dns=socket.gethostbyname(weblink)
    print("DNS:",dns)


   domain=Domain_name
   dns=dns
   data={"WEBSITE":weblink,"DOMAIN":domain,"DNS":dns}
   def alt():
       df=pd.DataFrame(data,index=[1])
       df.to_csv("data.csv",index=False,mode='a',header=False)
       print(df)
   alt()    

begin()

begin()
  • Related