output-formatting

Get rid from one column duplicate values in two column select

╄→尐↘猪︶ㄣ 提交于 2019-11-28 11:37:14
问题 So, I`ve got two columns t1.NAME and t2.ITEMS, for each neme there can be more than one item assigned to it, so I want to select it like: | NAME | ITEMS | JOHN 1 2 BEN 4 7 3 DAVE 5 P.s. if it helps, they are connected by t1.id = t2.names_id 回答1: Result of my below query is very close to what you want.. the only difference is, there is no blank name, because you cannot directly do that result in one step query.. each item belong to name of each id in t1. BUT you can do some trick there if you

Alternate output format for psql

六眼飞鱼酱① 提交于 2019-11-28 02:32:29
I am using PostgreSQL 8.4 on Ubuntu. I have a table with columns c1 through cN . The columns are wide enough that selecting all columns causes a row of query results to wrap multiple times. Consequently, the output is hard to read. When the query results constitute just a few rows, it would be convenient if I could view the query results such that each column of each row is on a separate line, e.g. c1: <value of row 1's c1> c2: <value of row 1's c1> ... cN: <value of row 1's cN> ---- some kind of delimiter ---- c1: <value of row 2's c1> etc. I am running these queries on a server where I would

How to format the output of kubectl describe to JSON

冷暖自知 提交于 2019-11-27 23:23:53
问题 kubectl get command has this flag -o to format the output. Is there a similar way to format the output of the kubectl describe command? For example: kubectl describe -o="jsonpath={...}" pods my-rc would print a JSON format for the list of pods in my-rc replication controller. But -o is not accepted for the describe command. 回答1: kubectl describe doesn't support -o or equivalent. It's meant to be human-readable rather than script-friendly. You can achieve what you described with kubectl get

Is there a way to output text to the R console in color

谁都会走 提交于 2019-11-27 21:48:01
I am writing a script and I want to output text messages to the console with different colors depending on conditions. For example: RED for errors and BLUE for warnings, etc. I am using RStudio. krlmlr Check out the new crayon package : library(crayon) cat(blue("Hello", "world!\n")) More info on the GitHub page . Works in RStudio 1.2.360+ The xterm256 package by Romain Francoise allows this sort of thing in general on any console that understands xterm256 interrupts. 来源: https://stackoverflow.com/questions/10802806/is-there-a-way-to-output-text-to-the-r-console-in-color

Removing display of row names from data frame

a 夏天 提交于 2019-11-27 03:53:14
I am creating a dataframe using this code: df <- data.frame(dbGetQuery(con, paste('select * from test'))) Which results in this: UID BuildingCode AccessTime 1 123456 BUILD-1 2014-06-16 07:00:00 2 364952 BUILD-2 2014-06-15 08:00:00 3 95865 BUILD-1 2014-06-06 09:50:00 I am then trying to remove the row names (1, 2, 3, etc) as suggested here by using this code: rownames(df) <- NULL But then when I print out df it still displays the row names. Is there a way to not include the row names when creating the data frame? I found a suggestion about row.name = FALSE but when I tried it I just got errors

Rewinding std::cout to go back to the beginning of a line

无人久伴 提交于 2019-11-27 02:14:06
I'm writing a command-line tool for Mac OS X that processes a bunch of files. I would like to show the user the current file being processed, but do not want a bazillion files polluting the terminal window. Instead I would like to use a single line to output the file path, then reuse that line for the next file. Is there a character (or some other code) to output to std::cout to accomplish this? Also, if I wanted to re-target this tool for Windows, would the solution be the same for both platforms? "\r" should work for both windows and Mac OS X. Something like: std::cout << "will not see this

avoid string printed to console getting truncated (in RStudio)

爷,独闯天下 提交于 2019-11-27 01:55:00
I want to print a long string to the RStudio console so that it does not get truncated. > paste(1:300, letters, collapse=" ") [1] "1 a 2 b 3 c 4 d 5 e 6 f 7 g 8 h 9 i ... 181 y 182 z 183 a 184 b... <truncated> I supposed this should be fairly simple, but I cannot figure out how. I tried options(max.print = 10000) and looked through the args on the print help pages. Still no luck. What parameter / settings to I have to change to achieve this? This is an RStudio-specific feature, intended to help resolve problems where printing overly long strings could cause IDE sluggishness. (I believe it was

Is there a way to output text to the R console in color

偶尔善良 提交于 2019-11-26 20:48:07
问题 I am writing a script and I want to output text messages to the console with different colors depending on conditions. For example: RED for errors and BLUE for warnings, etc. I am using RStudio. 回答1: Check out the new crayon package: library(crayon) cat(blue("Hello", "world!\n")) More info on the GitHub page. Works in RStudio 1.2.360+ 回答2: The xterm256 package by Romain Francoise allows this sort of thing in general on any console that understands xterm256 interrupts. 来源: https:/

Alternate output format for psql

♀尐吖头ヾ 提交于 2019-11-26 18:42:22
问题 I am using PostgreSQL 8.4 on Ubuntu. I have a table with columns c1 through cN . The columns are wide enough that selecting all columns causes a row of query results to wrap multiple times. Consequently, the output is hard to read. When the query results constitute just a few rows, it would be convenient if I could view the query results such that each column of each row is on a separate line, e.g. c1: <value of row 1's c1> c2: <value of row 1's c1> ... cN: <value of row 1's cN> ---- some

Formatting output in C++

浪尽此生 提交于 2019-11-26 13:52:05
问题 In a C++ code I have a matrix of double variables which I print out. However because all of them have different number of digits, the output format is destroyed. One solution is to do cout.precision(5) but I want different columns have a different precision. Also, because there are negative values in some cases, the presence of the - sign also causes problems. How to get around this and produce a properly formatted output? 回答1: Off the top of my head, you can use setw(int) to specify the