concatenation

How to concatenate pathname and relative pathname?

天大地大妈咪最大 提交于 2019-12-11 08:29:57
问题 I have a task where I need to concatenate 2 pathnames: absolute + relative in perl. The following describes what I am trying to achieve: dir1/dir2/dir3/ + ../filename => dir1/dir2/filename dir1/dir2/dir3/ + ../../filename => dir1/filename I have only solution that counts ".." in relative path, say X, then splits the absolute path into dirs and count them - Y and finally concatenates only Y-X dirs with filename. This seems too bulky and I wonder whether better solution exists (I am sure it

Concatenate/join rows in txt file w/ Python 3

我是研究僧i 提交于 2019-12-11 07:50:46
问题 Looking to clean up a .txt file from NMEA GPS. My current code is below. deletes = ['$GPGGA', '$GPGSA', '$GPGSV', '$PSRF156', ] searchquery = '$GPRMC' with open('Drive_home.txt_rf') as f1: with open('Drive_home_1.txt', 'w+') as f2: lines = f1.readlines() for i, line in enumerate(lines): if line.startswith(searchquery): if not any(delete in lines[i + 1] for delete in deletes): f2.write(line) f2.write(lines[i + 1]) Which outputs one txt. and looks like... $GPRMC 204249 A 3504.5449 N 8509.0603 W

SQL Assistance - Grouping other fields by common email

荒凉一梦 提交于 2019-12-11 07:46:37
问题 I'd appreciate any assistance people could provide with this one. I've tried to follow a couple of other posts (GROUP BY to combine/concat a column), but when I do this, it combines everything. I have a table in SQL that holds contact data. Some contacts in the database have the same email address, particularly admin@, accounts@, etc. We also have a list of contact preferences for each contact: Emergency Contact, Accounts, WHS, etc. I'm trying to select the results of the table, but only one

MySQL Arrays: Can this be done?

别来无恙 提交于 2019-12-11 07:45:11
问题 Is it possible to select the concatenation of all the results returned by a subquery? So if the subquery returns more than one row, I can somehow get all the results contained in a single string? 回答1: Sort of. What you can get is the concatenated result of all the rows that were grouped together using GROUP_CONCAT. You could use that to employ GROUP BY by a column that you know would group the result set correctly and then using the function to return the concated groups. The manual page

concatenate two strings that are in different lists

耗尽温柔 提交于 2019-12-11 06:46:59
问题 I need to concatenate two strings that are in different lists and check if the output string is in a dictionary. The code I've tried is: x=['casa','lo','pre','computer'] y=['music','sun','ve','sident','house'] dic=['sunday','love','president','house','computer'] text=[] errors=[] iter_y=iter(y) iter_x=iter(x) for i in iter_x: if i in dic: text.append(i) else: try: concatenated= i + next(iter_y) if concatenated in dic: text.append(concatenated) except StopIteration: continue else: errors

Change 2D array by 2D array of indices

不羁岁月 提交于 2019-12-11 06:43:54
问题 I have input array: np.random.seed(45) a = np.random.randint(100,size=(5,21)) print (a) [[75 30 3 32 95 61 85 35 68 15 65 14 53 57 72 87 46 8 53 12 34] [24 12 17 68 30 56 14 36 31 86 36 57 61 79 17 6 42 11 8 49 77] [75 63 42 54 16 24 95 63 98 22 27 32 16 75 58 60 54 96 70 32 16] [59 92 55 88 5 81 93 79 67 55 60 57 83 27 78 18 87 55 20 9 9] [73 27 57 50 7 57 78 68 23 75 41 39 70 2 71 70 27 47 54 93 19]] Array of indices: b = np.array( [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1

Concatenate multiple tokens for X macro

北慕城南 提交于 2019-12-11 06:18:11
问题 I'm trying to use X macros and preprocessor concatenation, both for the first time, together. I've read a lot of the other questions on SO related to preprocessor concatenation but not yet been able to wrap my head around them or how to adapt those to my use case. The list of items is a list of ID numbers for a bunch of structs , like so: #define LIST_OF_ID_NUMS \ X(1) \ X(2) \ X(3) \ X(4) \ X(5) \ X(6) \ X(7) \ X(8) \ X(9) \ X(10) \ X(11) I can declare the structs like so: #define X(id_num)

Adding columns of two relations in postgresql

倖福魔咒の 提交于 2019-12-11 05:38:27
问题 I have two relations such as relation1 and relation2. relation1 has columns of A,B,C and relation2 has columns of D,E,F. I want to add A of relation1 with D of relation2 where C = F. For the C values which do not exist in relation2 must appear and F values which do not appear in relation1 also must appear How to do this postgresql? 回答1: Use a FULL [OUTER] JOIN to include rows from either side without a matching row on the other side: SELECT COALESCE(r1.a, 0) + COALESCE(r2.d, 0) AS a_d FROM

Concatenate two SQL fields with text

倖福魔咒の 提交于 2019-12-11 05:27:17
问题 How can I concat two fields and text in between? I've tried all of the following and nothing has worked... ([fldCode1] || ':' ||[fldCode2]) AS Method ([fldCode1] + ':' + [fldCode2]) AS Method ([fldCode1] & ':' & [fldCode2]) AS Method *** & cannot be used with varchar 回答1: This should work select [fldCode1] + ':' + [fldCode2] from tab or if the columns are numeric select cast([fldCode1] as varchar(100)) + ':' + cast([fldCode2] as varchar(100)) from tab 回答2: The first and last forms are not

Concatenate two dataframes pyspark

十年热恋 提交于 2019-12-11 05:18:39
问题 I'm trying to concatenate two dataframes, which look like that: df1: +---+---+ | a| b| +---+---+ | a| b| | 1| 2| +---+---+ only showing top 2 rows df2: +---+---+ | c| d| +---+---+ | c| d| | 7| 8| +---+---+ only showing top 2 rows They both have the same number of rows, and I would like to do something like: +---+---+---+---+ | a| b| c| d| +---+---+---+---+ | a| b| c| d| | 1| 2| 7| 8| +---+---+---+---+ I tried: df1=df1.withColumn('c', df2.c).collect() df1=df1.withColumn('d', df2.d).collect()