Dataframe to csv,如何跳过csv文件中的行

oipij1gg  于 2022-12-06  发布在  其他
关注(0)|答案(1)|浏览(166)

我在我的项目Pandas Dataframe 工作到csv文件。行是基于输入this is what I mean :3创建的,所以问题是第一行不断变化,因为我循环脚本the results :3。还需要帮助循环脚本

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()

希望我的问题是可以理解的,任何人都可以帮助我尽快解决这个问题。

ryevplcw

ryevplcw1#

问题已经解决了,谢谢@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()

相关问题