plsql中導入csvs
If you are familiar with coding in SQL, there is a strong chance you do it in PgAdmin, MySQL, BigQuery, SQL Server, etc. But there are times you just want to use your SQL skills for quick analysis on a small/medium sized dataset.
如果您熟悉SQL編碼,則很有可能在PgAdmin , MySQL , BigQuery , SQL Server等中進行編碼。但是有時您只想使用SQL技能來對中小型大小進行快速分析。數據集。
With csvkit
you can run any SQL on your CSV files right in your command line.
使用csvkit
您可以在命令行中直接在CSV文件上運行任何SQL。
csvkit
is a suite of command-line tools for converting to and working with CSV, the king of tabular file formats. Once you have csvkit
installed you can use csvsql
to run your SQL commands.
csvkit
是一套命令行工具,用于轉換為表格格式文件之王CSV并與其一起使用。 一旦你有csvkit
安裝就可以使用csvsql
來運行SQL命令。
1.安裝 (1. Installation)
If you don’t have csvkit
installed, head over here and follow the installation instructions or if you’re familiar with pip
you can do the following.
如果您沒有安裝csvkit
,請csvkit
此處并按照安裝說明進行操作,或者如果您熟悉pip
,則可以執行以下操作。
pip install csvkit
You can view the csvkit
documentation using below.
您可以使用以下方法查看csvkit
文檔。
csvsql -h
2.語法 (2. Syntax)
Now that you are all set up, you can follow this simple structure to run your queries. It is essential to note the SQL query must be written in quotation marks and must be in a single line. No line breaks.
現在您已經完成了所有設置,可以按照以下簡單結構運行查詢。 請務必注意,SQL查詢必須用引號引起來并且必須在一行中。 沒有換行符。
csvsql --query "ENTER YOUR SQL QUERY HERE"
FILE_NAME.csv
That’s it! Follow this basic code skeleton, and you are good to go.
而已! 遵循此基本代碼框架,您就可以開始工作了。
Make sure you are in the same working directory as where the CSV file is located.
確保您與CSV文件位于同一工作目錄中。
3.例子 (3. Example)
Below is an example of setting the directory and getting our first SQL command up and running in.
以下是設置目錄并啟動并運行我們的第一個SQL命令的示例。
檢查目錄 (Check Directory)
pwd
設置工作目錄 (Set Working Directory)
Make sure the file you plan to use is in the same directory. My CSV file is in the /Documents
folder.
確保計劃使用的文件位于同一目錄中。 我的CSV文件位于/Documents
文件夾中。
cd ~/Documents
運行查詢 (Run Query)
Next, we can run the query usingcsvsql
接下來,我們可以使用csvsql
運行查詢


使用csvlook格式化查詢輸出 (Format Query Output with csvlook)
Piping with | csvlook
can improve how your outputted query format.
用| csvlook
| csvlook
可以改善輸出查詢格式的方式。


將查詢輸出保存到新的CSV (Save Query Output to a New CSV)
Using redirection with >
you can send you query output to a new file/location. Note running the code below will not output anything, since we are saving the output to a new file. The new query will save the output to the new csv file store_sales.csv
通過>
使用重定向,您可以將查詢輸出發送到新文件/位置。 請注意,由于我們將輸出保存到新文件中,因此運行下面的代碼不會輸出任何內容。 新查詢會將輸出保存到新的csv文件store_sales.csv

You are all set! Now you can run SQL on your CSV files for quick insights without the need to go through a database.
你們都準備好了! 現在,您可以在CSV文件上運行SQL,以快速了解情況,而無需通過數據庫。
If you are looking to learn more about SQL, check out my other articles.
如果您想了解有關SQL的更多信息,請查看我的其他文章。
SQL Cheatsheet
SQL備忘單
Date/Time Functions in SQL
SQL中的日期/時間函數
Using CTEs in SQL
在SQL中使用CTE
Introduction to Window Functions
窗口功能介紹
翻譯自: https://towardsdatascience.com/analyze-csvs-with-sql-in-command-line-233202dc1241
plsql中導入csvs
本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。 如若轉載,請注明出處:http://www.pswp.cn/news/389413.shtml 繁體地址,請注明出處:http://hk.pswp.cn/news/389413.shtml 英文地址,請注明出處:http://en.pswp.cn/news/389413.shtml
如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!