# 前言 只要用自然語言的想法下指令,ChatGPT的新功能「Code Interpreter」可以自動撰寫Python程式,透過程式自動處理將需要的文件與資料結果,一次整理完成。 <br> <br> <br> 可接受的檔案格式 -------------------------- **Text Files** * Plain text (.txt) * Comma-separated values (.csv) * Tab-separated values (.tsv) **Data Files** * JavaScript Object Notation (.json) * eXtensible Markup Language (.xml) * YAML Ain't Markup Language (.yaml) * Hierarchical Data Format (.hdf, .h5) * Python Pickle Format (.pkl) * Protocol Buffers (.pb) **Microsoft Office Files** * Word (.docx) * Excel (.xlsx) * PowerPoint (.pptx) **OpenDocument Files** * Text Document (.odt) * Spreadsheet (.ods) **PDF Files** * Portable Document Format (.pdf) **Image Files** * Portable Network Graphics (.png) * JPEG (.jpeg, .jpg) **Audio Files** * MP3 (.mp3) * Waveform Audio File Format (.wav) * Audio Interchange File Format (.aiff) <br> <br> <br> 支援的程式語言 -------------------------- ![](https://hackmd.io/_uploads/Skx81oCY2.png) <br> <br> <br> <br> **Q:** 可以直接編譯執行的程式語言有哪些 **A:** 在此特定的環境中,由於安全性和功能限制,我無法直接編譯或執行任何提供的程式碼。我不能進行網路存取、文件寫入或執行任何形式的外部程式碼。 然而,我可以幫助你分析和理解各種程式語言的代碼,包括但不限於 Python、Java、JavaScript、C、C++、C#、Ruby、Go、Rust、Swift、PHP、Perl、Scala、Kotlin、Julia、Lua、TypeScript 等等。 我也可以在此環境中使用 Python 來執行數學計算或數據分析任務,但我不能執行任何其他程式語言的程式碼。 <br> <br> <br> # 提升工作效率實戰例子 [[數據分析#69] ChatGPT Plus 大進化:一條龍數據分析實戰!5 分鐘解 Kaggle 題目示範](https://couplehonest.com/chatgpt-plus-code-interpreter-da-project/) <br> 手把手教學的資料處理,適合第一次使用的人。 內文提及重點:ChatGPT 有權將你匯入的資料拿進去他的模型中訓練,因此,切記不要把公司的機密資料外洩到這裡 (非常重要,打三顆星!)!如果你需要 ChatGPT 的分析脈絡 (例如幫你寫 code),你可以給他假資料 (資料欄位是真的,裡面的資料是假的),這樣就可以「請他幫你寫腳本」但是「又不會外流公司或你的私人資料」!!! [ChatGPT’s Code Interpreter Was Just Released. Here’s How It Will Change Data Science Forever.](https://artificialcorner.com/chatgpts-code-interpreter-was-just-released-here-s-how-it-will-change-data-science-forever-b1581c452f47)<br> 資料繪圖,內文呈現直方圖、折線圖、圓餅圖。(可參考內文英文指令,通常會比中文來的精確) [chatgpt 💬 + code interpreter 💻 experiments](https://github.com/SkalskiP/awesome-chatgpt-code-interpreter-experiments)<br> 內文使用code interpreter完成的任務 * Running Java Script app * Running YOLOv8 object detector * Detect and track face on the video * Classification of images from the MNIST dataset * Using OCR to extract text from images <br> <br> <br> 自己實戰 R轉Python code -------------------------- <br> 1. 上傳R檔案/貼上cod,要求轉譯成Python code。 ![](https://hackmd.io/_uploads/rkNU1-Bch.png) ![](https://hackmd.io/_uploads/HyqUkZBqn.png) ![](https://hackmd.io/_uploads/BJNtdeH5h.png) 結果因為過於複雜無法完整的轉成Pyhton。 <br> <br> 2. function區塊式的餵給code interpreter進行分析和轉譯成Python code(**較粗略**),成功轉成Python並能夠執行運作產生出結果。 ![](https://hackmd.io/_uploads/By-CuxB9h.png) <br> <br> 3. 完成所有轉換->執行結果與原本R檔案有差距。分別對function內特定R套件的功能再次要求轉譯成Python code(**較細節**) ![](https://hackmd.io/_uploads/rJIYagr92.png) <br> <br> 4. * **整理code**( 針對**重複部分**或**無用參數**進行刪減並撰寫得更精簡 ) * **優化執行效率**( 它無法直接發現**主要原因**在哪個code片段只會給予推測,得明確把code片段丟給他並且請他提出解決方法 ) **小結:** * 頻繁使用一個半小時會被限制一個半小時。 * code interpreter針對小範圍code片段能有效處理,無法處理大範圍code片段。 * code interpreter能夠接收py檔案進行理解、分析、優化並且提供更改後的code載點。 * chatGPT3.5 vs chatGPT4(code interpreter) ![](https://hackmd.io/_uploads/H1HZ5CVch.png) ![](https://hackmd.io/_uploads/rysEyLj52.png) <br> <br> <br> 運用code interpreter可實現任務 -------------------------- 1. **數據清理, 資料分析, 繪製圖表** 2. **code撰寫, code分析和優化, 檢查bug** 3. 圖片處理 4. 影片處理 5. 聲音編輯 6. QR code 7. 文字雲 8. 物件/臉部偵測 9. 交互式 3D 繪圖 10. 製作演講稿 (etc. <br> 上述任務可以在以下reference ChatGPT Code Interpreter - Ultimate Tutorial For Beginners 找到) <br> <br> <br> # Reference > [ChatGPT最新應用:不懂Python也沒關係,Code Interpreter幫你畫動畫圖、製作QR Code](https://www.thenewslens.com/article/188392) > [ChatGPT Code Interpreter - Ultimate Tutorial For Beginners](https://www.youtube.com/watch?v=xuSsk5Dy6uk) > [ChatGPT Code Interpreter: How It Saved Me Hours of Work](https://towardsdatascience.com/chatgpt-code-interpreter-how-it-saved-me-hours-of-work-3c65a8dfa935) > [ChatGPT’s Code Interpreter Was Just Released. Here’s How It Will Change Data Science Forever.](https://artificialcorner.com/chatgpts-code-interpreter-was-just-released-here-s-how-it-will-change-data-science-forever-b1581c452f47) > [[數據分析#69] ChatGPT Plus 大進化:一條龍數據分析實戰!5 分鐘解 Kaggle 題目示範](https://couplehonest.com/chatgpt-plus-code-interpreter-da-project/) > [ChatGPT’s Code Interpreter Was Just Released. Here’s How It Will Change Data Science Forever.](https://artificialcorner.com/chatgpts-code-interpreter-was-just-released-here-s-how-it-will-change-data-science-forever-b1581c452f47) > [chatgpt 💬 + code interpreter 💻 experiments](https://github.com/SkalskiP/awesome-chatgpt-code-interpreter-experiments)