偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

利用ChatGPT進(jìn)行數(shù)據(jù)清洗處理

原創(chuàng) 精選
開(kāi)發(fā)
最近c(diǎn)hatgpt非?;穑ㄟ^(guò)chatgpt可以做很多事情,筆者也通過(guò)實(shí)際使用解決了自己的問(wèn)題,都基本不用自己編程。

最近c(diǎn)hatgpt非常火,通過(guò)chatgpt可以做很多事情,筆者也通過(guò)實(shí)際使用解決了自己的問(wèn)題,都基本不用自己編程。

本文主要需要解決:

通過(guò)burpsuite批量獲取的json文件,需要處理成mysql數(shù)據(jù)庫(kù)識(shí)別的格式,方便入庫(kù)。

(1)重命名所有文件為txt后綴文件

(2)刪除txt文件無(wú)用的前N行數(shù)據(jù),其實(shí)就是頭文件數(shù)據(jù),有幾行就定義幾行。

(3)重命名txt文件為json文件。

(4)對(duì)json文件自動(dòng)識(shí)別表列名,并處理數(shù)據(jù)到一個(gè)文件中。

1.chatgpt嘗試  

 通過(guò)fofa.info搜索"loading-wrap" && "balls" && "chat" && is_domain=true,搜索的記錄就是提供chatgpt的網(wǎng)站地址。

圖片

2.逐個(gè)網(wǎng)站測(cè)試是否可以免費(fèi)使用

 打開(kāi)搜索中的記錄,逐個(gè)查看,有的需要輸入密碼才能方法,尋找一些免費(fèi)的chatgpt。

圖片

 對(duì)一些需要輸入驗(yàn)證的直接pass掉,然后尋找一些不需要密碼就能訪問(wèn)的。例如https://chat.77yun.cc/#/chat/1002

圖片

3.進(jìn)行實(shí)際測(cè)試

 可以在chatgpt中將自己的問(wèn)題提出來(lái),輸入回車后即可獲取相應(yīng)的解決方法。同時(shí)對(duì)實(shí)際數(shù)據(jù)進(jìn)行測(cè)試,不斷的訓(xùn)練,最后達(dá)到自己想要的結(jié)果。

圖片

圖片

4.最后的代碼為

import os
import json


#獲取指定目錄下所有的文件
dir = 'all'
all_files = [f for f in os.listdir(dir) if os.path.isfile(os.path.join(dir, f))]


for file in all_files:
    #將所有擴(kuò)展名不是.txt的文件改名為同名.txt文件
    if not file.endswith('.txt'):
        os.rename(os.path.join(dir, file), os.path.join(dir, os.path.splitext(file)[0] + '.txt'))
        file = os.path.splitext(file)[0] + '.txt'
    
    #對(duì)于每個(gè)txt文件,刪除前9行的內(nèi)容并保存到新的txt文件中
    with open(os.path.join(dir, file), 'r', encoding='utf-8') as txt_file:
        content = txt_file.readlines()


    deleted_content = '\n'.join(content[:9])
    new_content = ''.join(content[9:])
    with open(os.path.join(dir, file), 'w', encoding='utf-8') as txt_file:
        txt_file.write(new_content)
    
    #將新的txt文件重命名為同名.json文件,并讀取其內(nèi)容
    json_file = os.path.splitext(file)[0] + '.json'
    os.rename(os.path.join(dir, file), os.path.join(dir, json_file))
    
    with open(os.path.join(dir, json_file), 'r', encoding='utf-8') as j_file:
        data = json.load(j_file)
        columns = list(data['page']['list'][0].keys())
        rows = []
        
        for item in data['page']['list']:
            row_values = []
            for column in columns:
                value = str(item[column]).replace('\n','').replace(',','')
                row_values.append(value)
            rows.append(','.join(row_values))
        
        #整理json文件中的數(shù)據(jù),并按照列名的順序?qū)懭霐?shù)據(jù)文件out.txt中
        with open('out.txt', 'a+', encoding='utf-8') as out_file:
            if out_file.tell() == 0:
                out_file.write(','.join(columns) + '\n')
            out_file.write('\n'.join(rows)+'\n')
        
        print("文件{}中的數(shù)據(jù)已寫入out.txt文件中".format(json_file))

5.總結(jié)

  使用chatgpt編程非常簡(jiǎn)單,關(guān)鍵你需要定義好你需要的東西。例如我的功能描述如下:

(1)使用python代碼實(shí)現(xiàn)以下功能:當(dāng)前數(shù)據(jù)目錄為all

(2)原始代碼中首先對(duì)所有文件重命名為文件ren *.* *.txt 

(3)獲取指定目錄下所有的文件,并遍歷每個(gè)文件。

(4)將所有擴(kuò)展名不是 .txt 的文件重命名為同名的 .txt 文件,保證后續(xù)處理只考慮 txt 文件。

(5)對(duì)于每個(gè)txt文件,讀取文件內(nèi)容并刪除前9行的內(nèi)容,這一部分?jǐn)?shù)據(jù)在原代碼中被稱為“頭部?jī)?nèi)容”,然后將剩余內(nèi)容保存到新的txt文件中。

(6)將新的txt文件重命名為同名 .json 文件,并讀取其內(nèi)容。

(7)整理 json 文件中的數(shù)據(jù),并按照列名的順序?qū)懭霐?shù)據(jù)文件out.txt中。

 需要清晰的定義好想要的功能點(diǎn),然后通過(guò)不停的訓(xùn)練測(cè)試最終達(dá)到自己想要的效果??傊辛薱hatgpt后,你有產(chǎn)品的思路就可以,很多功能可以簡(jiǎn)化,有編程功底的人可以更好的利用。

責(zé)任編輯:龐桂玉 來(lái)源: 51CTO
相關(guān)推薦

2023-05-05 19:16:22

Python數(shù)據(jù)清洗

2024-12-19 15:00:00

數(shù)據(jù)清洗Python

2025-04-07 00:30:00

DeepSeek大數(shù)據(jù)數(shù)字化

2024-10-28 12:57:36

Pandas數(shù)據(jù)清洗

2022-03-28 14:08:02

Python數(shù)據(jù)清洗數(shù)據(jù)集

2023-05-30 18:05:00

chatgpthtml

2023-09-26 01:03:36

Pandas數(shù)據(jù)數(shù)據(jù)集

2021-07-27 15:40:39

Python數(shù)據(jù)清洗函數(shù)

2018-04-03 12:07:53

數(shù)據(jù)清洗PandasNumpy

2020-06-05 14:29:07

PythonPandas數(shù)據(jù)分析

2010-01-06 14:36:04

JSON插件

2012-03-21 09:31:51

ibmdw

2018-05-07 14:50:27

可視化數(shù)據(jù)散點(diǎn)圖

2023-09-27 15:34:48

數(shù)據(jù)編程

2024-07-26 21:36:43

2017-12-11 09:03:31

2021-07-17 22:41:53

Python數(shù)據(jù)技術(shù)

2022-01-26 09:00:00

數(shù)據(jù)庫(kù)SnowparkSQL

2011-03-09 14:18:37

SQL數(shù)據(jù)累加

2017-10-31 11:55:46

sklearn數(shù)據(jù)挖掘自動(dòng)化
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)