quoting

Rows are lost when reading this tab-separated file with pandas read_csv

孤街醉人 提交于 2019-12-03 13:11:55
问题 I have a .text file with following format, where fields (index number, name and message) are separated by \t (tab-separated): 712 ben Battle of the Books 713 james i used to be in TOM 714 tomy i was in BOB once 715 ben Tournaments of Minds 716 tommy Also the Lion in the upcoming school play 717 tommy Can you guess 718 tommy P ... which I read with read_csv into a data frame: chat = pd.read_csv("f.text", sep = "\t", header = None, usecols = [2]) But the data frame just has 9812 rows while the

Stripping single and double quotes in a string using bash / standard Linux commands only

徘徊边缘 提交于 2019-12-03 09:38:35
问题 I'm looking for something that will translate a string as follows, using only bash / standard Linux commands: Single-quotes surrounding a string should be removed Double-quotes surrounding a string should be removed Unquoted strings should remain the same Strings with unmatched surrounding quotes should remain the same Single-quotes that don't surround the string should remain Double-quotes that don't surround the string should remain For example: 'Food' should become Food "Food" should

clojure require syntax rationale

拜拜、爱过 提交于 2019-12-03 07:03:32
问题 I'm having a hard time understanding (and therefore remembering) the clojure require syntax described here: http://clojuredocs.org/clojure_core/1.3.0/clojure.core/require. It seems both counter intuitive and non-uniform. For example, in the following why is this vector required to be quoted: (require '[clj-json.core :as json]) Counter intuitive because normally vectors are not quoted in clojure (lists are quoted and vectors are treated as data). And non-uniform because in this case the vector

Rows are lost when reading this tab-separated file with pandas read_csv

廉价感情. 提交于 2019-12-03 04:06:50
I have a .text file with following format, where fields (index number, name and message) are separated by \t (tab-separated): 712 ben Battle of the Books 713 james i used to be in TOM 714 tomy i was in BOB once 715 ben Tournaments of Minds 716 tommy Also the Lion in the upcoming school play 717 tommy Can you guess 718 tommy P ... which I read with read_csv into a data frame: chat = pd.read_csv("f.text", sep = "\t", header = None, usecols = [2]) But the data frame just has 9812 rows while the ordinary file has more than 12428 rows (just 21 empty lines). It is quite weird. Do you have any idea?

General string quoting for TCL

前提是你 提交于 2019-12-03 01:45:22
I'm writing a utility (which happens to be in python) which is generating output in the form of a TCL script. Given some arbitrary string variable (not unicode) in the python, I want to produce a TCL line like set s something ... which will set TCL variable ' s ' to that exact string, regardless of what strange characters are in it. Without getting too weird, I don't want to make the output messier than needed. I believe a decent approach is if the string is not empty and contains only alphanumerics, and some characters like .-_ (but definitely not $"{}\ ) then it can be used as-is; if it

clojure require syntax rationale

烈酒焚心 提交于 2019-12-02 20:41:09
I'm having a hard time understanding (and therefore remembering) the clojure require syntax described here: http://clojuredocs.org/clojure_core/1.3.0/clojure.core/require . It seems both counter intuitive and non-uniform. For example, in the following why is this vector required to be quoted: (require '[clj-json.core :as json]) Counter intuitive because normally vectors are not quoted in clojure (lists are quoted and vectors are treated as data). And non-uniform because in this case the vector is NOT quoted: (ns xxx (:require [clj-json.core :as json])) I realize that the require function and

How do I extract column from CSV with quoted commas, using the shell?

懵懂的女人 提交于 2019-12-02 15:05:11
问题 I have a CSV file, but unlike in related questions, it has some columns containing double-quoted strings with commas, e.g. foo,bar,baz,quux 11,"first line, second column",13.0,6 210,"second column of second line",23.1,5 (of course it's longer, and the number of quoted commas is not necessarily one or 0, nor is the text predictable.) The text might also have (escaped) double-quotes within double-quotes, or not have double-quotes altogether for a typically-quoted field. The only assumption we

Get and use a password with special characters in Bash shell

杀马特。学长 韩版系。学妹 提交于 2019-12-02 14:21:52
问题 I'm getting some troubles to use a password with special characters such as $ in a bash shell script. My shell script is : read -s -p "Password : " bindDNPass ldapadd -H ldap://localhost -x -w $bindDNPass -D "dn=cn=Admin" -f /tmp/file.ldif And the password could be something like $Something18$. Well, the command ldapadd -H ldap://localhost -x -W -D "dn=cn=Admin" -f /tmp/file.ldif` asks for my $Something18$ , and works fine. But if I try ldapadd -H ldap://localhost -x -w $Something18$ -D "dn

How to pass commands as arguments to ssh [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-02 14:16:10
This question already has an answer here: Running shell command that has nested quotes via ssh 3 answers Double quotes inside quotes in bash 2 answers Escaping quotes when using SSH 2 answers My need is to make this command work: sshpass -p XXXX ssh -oStrictHostKeyChecking=no wsuser@192.168.0.100 sudo docker exec -u postgres postgres-container /bin/bash -c \" psql -d crawl-configuration -c 'select * from schema_version'\" But the result indicates that * is expanded by the shell and all matching files are passed as arguments to the psql command. So I searched how to protect the command from

How do I extract column from CSV with quoted commas, using the shell?

萝らか妹 提交于 2019-12-02 07:53:52
I have a CSV file, but unlike in related questions, it has some columns containing double-quoted strings with commas, e.g. foo,bar,baz,quux 11,"first line, second column",13.0,6 210,"second column of second line",23.1,5 (of course it's longer, and the number of quoted commas is not necessarily one or 0, nor is the text predictable.) The text might also have (escaped) double-quotes within double-quotes, or not have double-quotes altogether for a typically-quoted field. The only assumption we can make is that there are no quoted newlines, so we can split lines trivially using \n . Now, I'd like