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.mzph.cn/news/389413.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

计算机科学必读书籍_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.产品分类/产品分类是将产品…

交替最小二乘矩阵分解_使用交替最小二乘矩阵分解与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…

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…

火种 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…

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 …

乐高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…

图像灰度化与二值化

图像灰度化 什么是图像灰度化? 图像灰度化并不是将单纯的图像变成灰色,而是将图片的BGR各通道以某种规律综合起来,使图片显示位灰色。 规律如下: 手动实现灰度化 首先我们采用手动灰度化的方式: 其思想就是&#…

分析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…

上采样(放大图像)和下采样(缩小图像)(最邻近插值和双线性插值的理解和实现)

上采样和下采样 什么是上采样和下采样? • 缩小图像(或称为下采样(subsampled)或降采样(downsampled))的主要目的有 两个:1、使得图像符合显示区域的大小;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…

java 分裂数字_分裂的补充:超越数字,打印物理可视化

java 分裂数字As noted in my earlier Nightingale writings, color harmony is the process of choosing colors on a Color Wheel that work well together in the composition of an image. Today, I will step further into color theory by discussing the Split Compleme…

结构化数据建模——titanic数据集的模型建立和训练(Pytorch版)

本文参考《20天吃透Pytorch》来实现titanic数据集的模型建立和训练 在书中理论的同时加入自己的理解。 一,准备数据 数据加载 titanic数据集的目标是根据乘客信息预测他们在Titanic号撞击冰山沉没后能否生存。 结构化数据一般会使用Pandas中的DataFrame进行预处理…

比赛,幸福度_幸福与生活满意度

比赛,幸福度What is the purpose of life? Is that to be happy? Why people go through all the pain and hardship? Is it to achieve happiness in some way?人生的目的是什么? 那是幸福吗? 人们为什么要经历所有的痛苦和磨难? 是通过…

带有postgres和jupyter笔记本的Titanic数据集

PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.PostgreSQL是一个功能强大的开源对象关系数据库系统&am…

Django学习--数据库同步操作技巧

同步数据库:使用上述两条命令同步数据库1.认识migrations目录:migrations目录作用:用来存放通过makemigrations命令生成的数据库脚本,里面的生成的脚本不要轻易修改。要正常的使用数据库同步的功能,app目录下必须要有m…

React 新 Context API 在前端状态管理的实践

2019独角兽企业重金招聘Python工程师标准>>> 本文转载至:今日头条技术博客 众所周知,React的单向数据流模式导致状态只能一级一级的由父组件传递到子组件,在大中型应用中较为繁琐不好管理,通常我们需要使用Redux来帮助…

机器学习模型 非线性模型_机器学习模型说明

机器学习模型 非线性模型A Case Study of Shap and pdp using Diabetes dataset使用糖尿病数据集对Shap和pdp进行案例研究 Explaining Machine Learning Models has always been a difficult concept to comprehend in which model results and performance stay black box (h…

5分钟内完成胸部CT扫描机器学习

This post provides an overview of chest CT scan machine learning organized by clinical goal, data representation, task, and model.这篇文章按临床目标,数据表示,任务和模型组织了胸部CT扫描机器学习的概述。 A chest CT scan is a grayscale 3…

Pytorch高阶API示范——线性回归模型

本文与《20天吃透Pytorch》有所不同,《20天吃透Pytorch》中是继承之前的模型进行拟合,本文是单独建立网络进行拟合。 代码实现: import torch import numpy as np import matplotlib.pyplot as plt import pandas as pd from torch import …