plsql中導入csvs_在命令行中使用sql分析csvs

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運行查詢

Image for post
code
Image for post
output
輸出

使用csvlook格式化查詢輸出 (Format Query Output with csvlook)

Piping with | csvlook can improve how your outputted query format.

| csvlook | csvlook可以改善輸出查詢格式的方式。

Image for post
code
Image for post
output
輸出

將查詢輸出保存到新的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

Image for post

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,一經查實,立即刪除!

相關文章

第十八篇 Linux環境下常用軟件安裝和使用指南

提醒:如果之后要安裝virtualenvwrapper的話,可以直接跳到安裝virtualenvwrapper的方法,而不需要先安裝好virtualenv安裝virtualenv和生成虛擬環境安裝virtualenv:yum -y install python-virtualenv生成虛擬環境:先切換…

莫煩Matplotlib可視化第三章畫圖種類代碼學習

3.1散點圖 import matplotlib.pyplot as plt import numpy as npn 1024 X np.random.normal(0,1,n) Y np.random.normal(0,1,n) T np.arctan2(Y,X) #用于計算顏色plt.scatter(X,Y,s75,cT,alpha0.5)#alpha是透明度 #plt.scatter(np.arange(5),np.arange(5)) #一條線的散點…

計算機科學必讀書籍_5篇關于數據科學家的產品分類必讀文章

計算機科學必讀書籍Product categorization/product classification is the organization of products into their respective departments or categories. As well, a large part of the process is the design of the product taxonomy as a whole.產品分類/產品分類是將產品…

es6解決回調地獄問題

本文摘抄自阮一峰老師的 http://es6.ruanyifeng.com/#docs/generator-async 異步 所謂"異步",簡單說就是一個任務不是連續完成的,可以理解成該任務被人為分成兩段,先執行第一段,然后轉而執行其他任務,等做好…

交替最小二乘矩陣分解_使用交替最小二乘矩陣分解與pyspark建立推薦系統

交替最小二乘矩陣分解pyspark上的動手推薦系統 (Hands-on recommender system on pyspark) Recommender System is an information filtering tool that seeks to predict which product a user will like, and based on that, recommends a few products to the users. For ex…

莫煩Matplotlib可視化第四章多圖合并顯示代碼學習

4.1Subplot多合一顯示 import matplotlib.pyplot as plt import numpy as npplt.figure() """ 每個圖占一個位置 """ # plt.subplot(2,2,1) #將畫板分成兩行兩列,選取第一個位置,可以去掉逗號 # plt.plot([0,1],[0,1]) # # plt.su…

python 網頁編程_通過Python編程檢索網頁

python 網頁編程The internet and the World Wide Web (WWW), is probably the most prominent source of information today. Most of that information is retrievable through HTTP. HTTP was invented originally to share pages of hypertext (hence the name Hypertext T…

Python+Selenium自動化篇-5-獲取頁面信息

1.獲取頁面title title:獲取當前頁面的標題顯示的字段from selenium import webdriver import time browser webdriver.Chrome() browser.get(https://www.baidu.com) #打印網頁標題 print(browser.title) #輸出內容:百度一下,你就知道 2.…

火種 ctf_分析我的火種數據

火種 ctfOriginally published at https://www.linkedin.com on March 27, 2020 (data up to date as of March 20, 2020).最初于 2020年3月27日 在 https://www.linkedin.com 上 發布 (數據截至2020年3月20日)。 Day 3 of social distancing.社會疏離的第三天。 As I sit on…

莫煩Matplotlib可視化第五章動畫代碼學習

5.1 Animation 動畫 import numpy as np import matplotlib.pyplot as plt from matplotlib import animationfig,ax plt.subplots()x np.arange(0,2*np.pi,0.01) line, ax.plot(x,np.sin(x))def animate(i):line.set_ydata(np.sin(xi/10))return line,def init():line.set…

data studio_面向營銷人員的Data Studio —報表指南

data studioIn this guide, we describe both the theoretical and practical sides of reporting with Google Data Studio. You can use this guide as a comprehensive cheat sheet in your everyday marketing.在本指南中,我們描述了使用Google Data Studio進行…

人流量統計系統介紹_統計介紹

人流量統計系統介紹Its very important to know about statistics . May you be a from a finance background, may you be data scientist or a data analyst, life is all about mathematics. As per the wiki definition “Statistics is the discipline that concerns the …

pyhive 連接 Hive 時錯誤

一、User: xx is not allowed to impersonate xxx 解決辦法&#xff1a;修改 core-site.xml 文件&#xff0c;加入下面的內容后重啟 hadoop。 <property><name>hadoop.proxyuser.xx.hosts</name><value>*</value> </property><property…

樂高ev3 讀取外部數據_數據就是新樂高

樂高ev3 讀取外部數據When I was a kid, I used to love playing with Lego. My brother and I built almost all kinds of stuff with Lego — animals, cars, houses, and even spaceships. As time went on, our creations became more ambitious and realistic. There were…

圖像灰度化與二值化

圖像灰度化 什么是圖像灰度化&#xff1f; 圖像灰度化并不是將單純的圖像變成灰色&#xff0c;而是將圖片的BGR各通道以某種規律綜合起來&#xff0c;使圖片顯示位灰色。 規律如下&#xff1a; 手動實現灰度化 首先我們采用手動灰度化的方式&#xff1a; 其思想就是&#…

分析citibike數據eda

數據科學 (Data Science) CitiBike is New York City’s famous bike rental company and the largest in the USA. CitiBike launched in May 2013 and has become an essential part of the transportation network. They make commute fun, efficient, and affordable — no…

jvm感知docker容器參數

docker中的jvm檢測到的是宿主機的內存信息&#xff0c;它無法感知容器的資源上限&#xff0c;這樣可能會導致意外的情況。 -m參數用于限制容器使用內存的大小&#xff0c;超過大小時會被OOMKilled。 -Xmx: 默認為物理內存的1/4。 4核CPU16G內存的宿主機 java 7 docker run -m …

Flask之flask-script 指定端口

簡介 Flask-Scropt插件為在Flask里編寫額外的腳本提供了支持。這包括運行一個開發服務器&#xff0c;一個定制的Python命令行&#xff0c;用于執行初始化數據庫、定時任務和其他屬于web應用之外的命令行任務的腳本。 安裝 用命令pip和easy_install安裝&#xff1a; pip install…

上采樣(放大圖像)和下采樣(縮小圖像)(最鄰近插值和雙線性插值的理解和實現)

上采樣和下采樣 什么是上采樣和下采樣&#xff1f; ? 縮小圖像&#xff08;或稱為下采樣&#xff08;subsampled&#xff09;或降采樣&#xff08;downsampled&#xff09;&#xff09;的主要目的有 兩個&#xff1a;1、使得圖像符合顯示區域的大小&#xff1b;2、生成對應圖…

r語言繪制雷達圖_用r繪制雷達蜘蛛圖

r語言繪制雷達圖I’ve tried several different types of NBA analytical articles within my readership who are a group of true fans of basketball. I found that the most popular articles are not those with state-of-the-art machine learning technologies, but tho…