cut

How do I format a Date field of a .CSV file with multiple commas in a string field

感情迁移 提交于 2019-12-10 10:09:29
问题 I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in between","4432","author1, name","890","88","11-OCT-11","12" "4432","B000QRIGJ4","890","another, string with quotes, and with more than, two commas: in between","455","author2, name","12","455","12-OCT-11","55" "11",

How to delete a column/columns of a CSV file which has cell values with a string enclosed in double quotes

时光毁灭记忆、已成空白 提交于 2019-12-10 07:22:34
问题 How can I delete a column from a CSV file which has comma separated value with a string enclosed in double quotes and a comma in between? I have a file 44.csv with 4 lines including the header like the below format: column1, column2, column3, column 4, column5, column6 12,455,"string with quotes, and with a comma in between",4432,6787,890,88 4432,6787,"another, string with quotes, and with two comma in between",890,88,12,455 11,22,"simple string",77,777,333,22 I need to cut the 1,2,3 columns

Cut polygons using contour line beneath the polygon layers

偶尔善良 提交于 2019-12-10 02:49:58
问题 I would like to cut a polygon layer, according to the elevation, into two parts (upper and lower part). The polygon might convex or concave, and the position to cut might vary from each other. The contour line has an interval of 5m, which means I might need to generate a contour with much condensed contour lines, e.g, 1m interval. Any idea on how to do it, better in ArcGIS, or in R? Below is the running example for the Q: library(sp) library(raster) r<-raster(ncol=100,nrow=100) values(r)<-rep

How to cut part of a string in c?

喜你入骨 提交于 2019-12-09 10:06:35
问题 I'm trying to figure out how to cut part of a string in C. For example you have this character string "The dog died because a car hit him while it was crossing the road" how would a function go making the sentence "a car hit him while crossing the road" or "a car hit him" How do you go about this with C's library (or/and) a custom function? ok I don't have the main code but this is going to be the structure of this experiment #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include

Having NA level for missing values with cut function from R

白昼怎懂夜的黑 提交于 2019-12-08 21:43:03
问题 The cut function in R omits NA. But I want to have a level for missing values. Here is my MWE. set.seed(12345) Y <- c(rnorm(n = 50, mean = 500, sd = 1), NA) Y1 <- cut(log(Y), 5) Labs <- levels(Y1) Labs [1] "(6.21,6.212]" "(6.212,6.213]" "(6.213,6.215]" "(6.215,6.217]" "(6.217,6.219]" Desired Output [1] "(6.21,6.212]" "(6.212,6.213]" "(6.213,6.215]" "(6.215,6.217]" "(6.217,6.219]" "NA" 回答1: You could use addNA Labs <- levels(addNA(Y1)) Labs #[1] "(6.21,6.212]" "(6.212,6.213]" "(6.213,6.215]" "

Sort bins from pandas cut

吃可爱长大的小学妹 提交于 2019-12-08 18:45:00
问题 Using pandas cut I can define bins by providing the edges and pandas creates bins like (a, b] . My question is how can I sort the bins (from the lowest to the highest)? import numpy as np import pandas as pd y = pd.Series(np.random.randn(100)) x1 = pd.Series(np.sign(np.random.randn(100))) x2 = pd.cut(pd.Series(np.random.randn(100)), bins = [-3, -0.5, 0, 0.5, 3]) model = pd.concat([y, x1, x2], axis = 1, keys = ['Y', 'X1', 'X2']) I have an intermediate result where the order of the bins is

Assigning echo and cut command to a variable

人盡茶涼 提交于 2019-12-08 08:07:43
问题 I'm trying to get the string "boo" from "upper/lower/boo.txt" and assign it to a variable. I was trying NAME= $(echo $WHOLE_THING | rev | cut -d "/" -f 1 | rev | cut -d "." -f 1) but it comes out empty. What am I doing wrong? 回答1: Don't do it that way at all. Much more efficient is to use built-in shell operations rather than out-of-process tools such as cut and rev . whole_thing=upper/lower/boo.txt name=${whole_thing##*/} name=${name%%.*} See BashFAQ #100 for a general introduction to best

merge files using cut and paste

落花浮王杯 提交于 2019-12-08 04:52:45
问题 i am trying to paste some large of files together. I would like to use paste. All the data has the same two column and i only want to print these two columns once. For example file1 h1 h2 i1 1 10 aa 2 20 bb 3 30 cc file2 h1 h2 i2 1 10 xx 2 20 yy 3 30 zz finaloutput h1 h2 i1 i2 1 10 aa xx 2 20 bb yy 3 30 cc zz I have around 3000 small files that need to be merged like this. I was wondering if there is a practical way of doing this? I can only think of using cut for each file and rename them

Cut video with ffmpeg.

二次信任 提交于 2019-12-07 02:11:26
This is my idea. I want to cut the first 10s of video and the last 10s of video Thank for help With re-encoding: ffmpeg -ss 10 -i video.mp4 -filter_complex "[0]trim=10,setpts=PTS-STARTPTS[b];[b][0]overlay=shortest=1" -shortest -c:a copy out.mp4 -ss 10 sets the the amount to cut from beginning. trim=10 sets amount to cut from end. Caveat here is that due to a current bug with shortest=1 , this may not work on ffmpeg builds from 2017. A bit of a hack method, which skips transcoding: ffmpeg -ss 10 -i video.mp4 -ss 20 -i video.mp4 -c copy -map 1:0 -map 0 -shortest -f nut - | ffmpeg -f nut -i -

Add '\\n' after a specific number of delimiters

荒凉一梦 提交于 2019-12-06 14:21:32
How can I add a \n after each four ; delimiter in a CSV file (with bash)? Input file sample: aaaa;bbbbbb;cccc;ddddd;eeee;ffff;gggg;hhhh;iii;jjjj;kkkk;llll; Output needed : aaaa;bbbbbb;cccc;ddddd eeee;ffff;gggg;hhhh iii;jjjj;kkkk;llll Using (GNU) sed : ... | sed -r 's/([^;]*;){4}/&\n/g' [^;]*; matches a sequence of characters that are not semicolons followed by a semicolon. (...){4} matches 4 times the expression inside the parentheses. & in the replacement is the whole match that was found. \n is a newline character. The modifier g make sed replace all matches in each input line instead of