table1:
test1 test2 test3 rest1 rest2
1 a z 21 82
2 s z 26 81
2 a z 54 82
Expected result:
rest1 rest2 Filed1 filed2
21 82 test1 1
26 81 test2 a
54 82 test3 z
21 82 test1 2
26 81 test2 s
54 82 test3 z
21 82 test1 2
26 81 test2 a
54 82 test3 z
I tried transform, pivot, union, but unable to achieve the above.
There might be a way to do this more gracefully in Access, e.g. using crosstabs, but one simple approach would be to just use unions:
SELECT rest1, rest2, 'test1' AS Filed1, test1 AS Filed 2 FROM table1 UNION ALL
SELECT rest1, rest2, 'test2', test2 FROM table1 UNION ALL
SELECT rest1, rest2, 'test3', test3 FROM table1
Related
I have two sets of data files in .sav (EMR.sav and APP.sav)
What I want to do, it merge the two data of EMR and APP, to do "comparison of steps by sex".
The data of EMR is as follows:
pid sex
306 1
866 1
896 1
921 2
The data of APP would be something like this(the A_id would equal to pid in EMR):
A_id A_calorie A_distance
866 124 14
866 24 24
866 13 35
866 12 23
866 23 0
921 101 23
921 12 13
921 19 24
921 200 235
921 232 241
The result I want to get is the two data files to merge and have:
pid sex A_calorie A_distance
866 1 124 14
866 1 24 24
866 1 13 35
866 1 12 23
866 1 23 0
921 2 101 23
921 2 12 13
921 2 19 24
921 2 200 235
921 2 232 241
But, what I keep getting is
pid sex A_calorie A_distance
866 1 124 14
866 . 24 24
866 . 13 35
866 . 12 23
866 . 23 0
921 2 101 23
921 . 12 13
921 . 19 24
921 . 200 235
921 . 232 241
How can I get all the same pid have the same sex value??
By the way, if it was R, one would use something like merge(EMR, APP, key=pid)
You can sort the files and use match files to get what you need:
get file=" ...... EMR ...... ".
sort cases by pid.
dataset name EMR.
get file=" ...... APP ...... ".
dataset name APP.
sort cases by A_id.
match files /file=* /rename A_id=pid /table=EMR /by pid.
exe.
I'm trying to read a file of multiple lines with two digit numbers on each line representing a binary tree structure. I'm using dart and the standard io library. This is the code I'm using:
String contents = new File('./assets/triangle.txt').readAsStringSync();
Problem is I get the following error:
max_path_sum/assets/triangle.txt:1:1: Error: Expected a declaration, but got '75'.
75
^^
max_path_sum/assets/triangle.txt:2:1: Error: Expected a declaration, but got '95'.
95 64
^^
max_path_sum/assets/triangle.txt:2:4: Error: Expected a declaration, but got '64'.
95 64
^^
max_path_sum/assets/triangle.txt:3:1: Error: Expected a declaration, but got '17'.
17 47 82
^^
max_path_sum/assets/triangle.txt:3:4: Error: Expected a declaration, but got '47'.
17 47 82
^^
max_path_sum/assets/triangle.txt:3:7: Error: Expected a declaration, but got '82'.
17 47 82
^^
max_path_sum/assets/triangle.txt:4:1: Error: Expected a declaration, but got '18'.
18 35 87 10
^^
max_path_sum/assets/triangle.txt:4:4: Error: Expected a declaration, but got '35'.
18 35 87 10
^^
max_path_sum/assets/triangle.txt:4:7: Error: Expected a declaration, but got '87'.
18 35 87 10
^^
max_path_sum/assets/triangle.txt:4:10: Error: Expected a declaration, but got '10'.
18 35 87 10
^^
This is the file I'm trying to read:
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
I've tried different variations of reading the file. Asynchronously, synchronously, line by line, the whole file in one string but keep getting the same error. It obviously reads the lines but seem to expect some other form of input and is not happy with just giving me the data it reads... All examples I find on the web indicate that the code is correct and it should work. So my guess is that I might have to do something with the input file in order for it to be accepted as a valid input but it would seem unpractical since it is able to read the data just fine as it is.
I found the issue. The following formatting of the file works for the first line:
var a = "75";
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
So I guess if I make the contents of the file into a string variable it will be fine. But why is this? Isn't it possible to read an ordinary text file in dart without having to change the contents first?
Problem was that I imported the text file using import statement which is probably why dart expected it to be code.
I want to combine two files that are very different without any row matching:
File 1 (1000+ rows):
M03558 203 5 23464 CTTGTA
M03559 205 3 1096 CTTGTQ
M03560 209 12 1956 CTTGTW
M035561 304 5 2347 CTTGTK
...
File 2 (a table of 3 rows):
A 12 34 78 0.3
B 13 35 79 0.3
C 14 36 80 0.5
Desired outcome:
M03558 203 5 23464 CTTGTA A 12 34 78 0.3
M03559 205 3 1096 CTTGTQ B 13 35 79 0.3
M03560 209 12 1956 CTTGTW C 14 36 80 0.5
M03561 304 5 2347 CTTGTK
...
Is there any way to achieve that in bash, perl, python or R, please?
In linux you can use the paste command:
paste -d " " file1 file2 > outfile
If, instead of a space seperating the two merged records, you wanted a tab character then:
paste -d "\t" file1 file2 > outfile
i follow the tutorial from matt on:
http://jhipster.github.io/video-tutorial/
when i do cloc . i see i have much and much more files i would expect:
$ cloc .
66717 text files.
20401 unique files.
24466 files ignored.
http://cloc.sourceforge.net v 1.60 T=128.46 s (115.7 files/s, 15523.0 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
Javascript 13322 222956 357190 1266221
HTML 676 6984 1047 44885
CSS 76 1883 932 22029
Java 262 3548 1854 15641
XML 53 3383 1395 11307
LESS 79 1388 1546 7269
C/C++ Header 18 1032 300 5109
YAML 190 221 346 3466
CoffeeScript 47 783 699 2467
make 58 417 523 1271
Bourne Shell 31 234 202 1097
Maven 1 12 34 824
Perl 2 87 170 584
DTD 1 179 177 514
SASS 5 42 25 273
C++ 4 43 26 260
IDL 6 38 0 167
Bourne Again Shell 3 28 36 140
D 6 0 0 118
Scala 1 16 7 118
JavaServer Faces 3 3 0 109
Smarty 6 17 30 91
DOS Batch 1 24 2 64
Python 1 7 7 36
XSLT 1 5 0 32
C# 2 3 1 27
ASP.Net 2 5 0 23
C 1 7 4 23
OCaml 1 5 15 6
Lisp 1 0 0 6
PowerShell 1 2 2 4
Lua 1 0 0 2
--------------------------------------------------------------------------------
SUM: 14862 243352 366570 1384183
--------------------------------------------------------------------------------
why is that?
in total it is 610 mb large!
it seems there are a lot of node modules:
$ du -h -d1
584M ./node_modules
24K ./gulp
26M ./src
64K ./.mvn
610M .
is this correct?
and what do i need to add to source control?
thanks
This is normal. Most of those files are NPM dependencies, as you mentioned.
The generated .gitignore should already be configured properly and will ignore node_modules.
This may be a stupid question, but I want a simpler way to replicate this technique used by Jon Erikson in the art of exploitation. In it he fills a .bin file using a bunch of complicated stuff grepping for source code and so forth.
$ for i in $(head exploit_notesearch.c | grep "^\"" | cut -d\" -f2)
do
echo -en $i
done > shellcode.bin
This generates a file like so:
hexdump -C shellcode.bin
00000000 48 31 f6 48 31 d2 48 bb 2f 62 69 6e 2f 73 68 11 |H1.H1.H./bin/sh.|
00000010 48 c1 e3 08 48 c1 eb 08 53 48 c7 c0 3b 11 11 11 |H...H...SH..;...|
00000020 48 89 e7 48 c1 e0 38 48 c1 e8 38 0f 05 |H..H..8H..8..|
0000002d
cat shellcode.bin
H1�H1�H�/bin/shH�H�SH��;H��H��8H��8
I don't know how to replicate this witchcraft, how can I make an exact replica using different commands? I tried
cat > new.bin
x48x31xf6x48x31xd2x48xbbx2fx62x69x6ex2fx73x68x11x48xc1xe3x08x48xc1xe3x08x53x48xc7xc0x3bx11x11x11x48x89xe7x48xc1xe0x38x48xc1xe8x38x0fx05
cat new.bin
x48x31xf6x48x31xd2x48xbbx2fx62x69x6ex2fx73x68x11x48xc1xe3x08x48xc1xe3x08x53x48xc7xc0x3bx11x11x11x48x89xe7x48xc1xe0x38x48xc1xe8x38x0fx05
hexdump -C new.bin
00000000 78 34 38 78 33 31 78 66 36 78 34 38 78 33 31 78 |x48x31xf6x48x31x|
00000010 64 32 78 34 38 78 62 62 78 32 66 78 36 32 78 36 |d2x48xbbx2fx62x6|
00000020 39 78 36 65 78 32 66 78 37 33 78 36 38 78 31 31 |9x6ex2fx73x68x11|
00000030 78 34 38 78 63 31 78 65 33 78 30 38 78 34 38 78 |x48xc1xe3x08x48x|
00000040 63 31 78 65 33 78 30 38 78 35 33 78 34 38 78 63 |c1xe3x08x53x48xc|
00000050 37 78 63 30 78 33 62 78 31 31 78 31 31 78 31 31 |7xc0x3bx11x11x11|
00000060 78 34 38 78 38 39 78 65 37 78 34 38 78 63 31 78 |x48x89xe7x48xc1x|
00000070 65 30 78 33 38 78 34 38 78 63 31 78 65 38 78 33 |e0x38x48xc1xe8x3|
00000080 38 78 30 66 78 30 35 0a |8x0fx05.|
00000088
I hardly knew how to ask this question and am not aware of anywhere else to look. I am grateful for any help. Thanks.
The tool you are looking for is xxd, which is normally used to get a hex dump of a binary file, but can also be used to perform a reverse hex dump, which is what you are trying to do.
Put your ascii hex into a file called Input.txt, without any of the x's.
4831f64831d248bb2f62696e2f73681148c1e30848c1e3085348c7c03b1111114889e748c1e03848c1e8380f05
Next, run xxd with the flag -p for plain, and -r for reverse.
xxd -r -p Input.txt Output.bin
Now, the desired output should be in Output.bin.
hexdump -C Output.bin
00000000 48 31 f6 48 31 d2 48 bb 2f 62 69 6e 2f 73 68 11 |H1.H1.H./bin/sh.|
00000010 48 c1 e3 08 48 c1 e3 08 53 48 c7 c0 3b 11 11 11 |H...H...SH..;...|
00000020 48 89 e7 48 c1 e0 38 48 c1 e8 38 0f 05 |H..H..8H..8..|
0000002d