This is workfile.txt
NC_001778
NC_005252
NC_004744
NC_003096
NC_005803
I want to read it in array and have only the string without spaces or lines .
this code does what I want on my laptop but it's not working on the linux desktop!
#nodes=<nodefile>;
chomp #nodes;
foreach my $el(#nodes){
chop ($el);
}
print Dumper #nodes;
#output: `bash-4.2$ perl main.pl
';AR1 = 'NC_000893
';AR2 = 'NC_001778
';AR3 = 'NC_005252
';AR4 = 'NC_004744
';AR5 = 'NC_003096
';AR6 = 'NC_005803
`
#hexdump -C workfile.txt |head -20
00000000 4e 43 5f 30 30 30 38 39 33 0d 0d 0a 4e 43 5f 30 |NC_000893...NC_0|
00000010 30 31 37 37 38 0d 0d 0a 4e 43 5f 30 30 35 32 35 |01778...NC_00525|
00000020 32 0d 0d 0a 4e 43 5f 30 30 34 37 34 34 0d 0d 0a |2...NC_004744...|
00000030 4e 43 5f 30 30 33 30 39 36 0d 0d 0a 4e 43 5f 30 |NC_003096...NC_0|
00000040 30 35 38 30 33 0d 0d 0a 4e 43 5f 30 30 36 35 33 |05803...NC_00653|
00000050 31 0d 0d 0a 4e 43 5f 30 30 34 34 31 37 0d 0d 0a |1...NC_004417...|
00000060 4e 43 5f 30 31 33 36 33 33 0d 0d 0a 4e 43 5f 30 |NC_013633...NC_0|
00000070 31 33 36 31 38 0d 0d 0a 4e 43 5f 30 30 32 37 36 |13618...NC_00276|
00000080 31 0d 0d 0a 4e 43 5f 30 31 33 36 32 38 0d 0d 0a |1...NC_013628...|
00000090 4e 43 5f 30 30 35 32 39 39 0d 0d 0a 4e 43 5f 30 |NC_005299...NC_0|
000000a0 31 33 36 30 39 0d 0d 0a 4e 43 5f 30 31 33 36 31 |13609...NC_01361|
000000b0 32 0d 0d 0a 4e 43 5f 30 30 32 36 34 36 0d 0d 0a |2...NC_002646...|
000000c0 4e 43 5f 30 30 34 35 39 35 0d 0d 0a 4e 43 5f 30 |NC_004595...NC_0|
000000d0 30 32 37 33 34 0d 0d 0a 4e 43 5f 30 30 34 35 39 |02734...NC_00459|
000000e0 38 0d 0d 0a 4e 43 5f 30 30 34 35 39 34 0d 0d 0a |8...NC_004594...|
000000f0 4e 43 5f 30 30 38 34 34 38 0d 0d 0a 4e 43 5f 30 |NC_008448...NC_0|
00000100 30 34 35 39 33 0d 0d 0a 4e 43 5f 30 30 32 36 34 |04593...NC_00264|
00000110 37 0d 0d 0a 4e 43 5f 30 30 32 36 37 34 0d 0d 0a |7...NC_002674...|
00000120 4e 43 5f 30 30 33 31 36 33 0d 0d 0a 4e 43 5f 30 |NC_003163...NC_0|
00000130 30 33 31 36 34 0d 0d 0a 4e 43 5f 30 32 30 31 35 |03164...NC_02015|
any suggestion ? thanks in advance
The problem is that you have Windows line endings in this file, which is why when you use linux, your chomp is not removing line endings properly. It does not explain why chop does not remove the last character, which should be \r after chomp.
Your output
';AR6 = 'NC_005803
Indicates that the last character in the string is in fact \r. This is not an actual problem with the string, just with the visual representation. If you want to see this character written out literally, you can use the option
$Data::Dumper::Useqq = 1;
Which will then produce the output
$VAR6 = "NC_005803\r";
How to fix it?
A simple fix is to use the dos2unix utility in linux to fix the file. To fix it in Perl, you can do something like
s/[\r\n]*\z// for #nodes; # remove all \r and \n from end of string
s/\s*\z// for #nodes; # remove all whitespace from end of string
s/\r//g for #nodes; # remove all \r from string
tr/\r//d for #nodes; # same
Related
im using pyspark 2.4 to consume from Kafka, but when casting the Value column that contain the messages
it appears like that == > like in the table below => �����īVAL ,
knowing that im just consuming ( i do not know how the producer was made)
i just know that its sent from postgre to kafka topic ,
then i consume it via pyspark from this kafka topic
and the sent data is JSON
is there somethin wrong with my consumer ?
kafka_messages : DataFrame = self.sparkSession.read \
.format("kafka") \
.option("kafka.bootstrap.servers", self.bootstrap_server) \
.option("kafka.security.protocol", "SASL_PLAINTEXT") \
.option("subscribe", self.topic) \
.option("startingOffsets", offset_option) \
.load()
def decode_and_flatten_msg_value(df, schema) -> DataFrame:
df = (
df
.select(df['value'].cast('string'))
.select(F.from_json(F.col("value"), schema).alias("data"))
.select("data.*")
.na
.drop('all')
)
return df
here an example of the message before cast to string the value column :
+--------------------+--------------------+--------------------+---------+------+--------------------+-------------+
| key| value| topic|partition|offset| timestamp|timestampType|
+--------------------+--------------------+--------------------+---------+------+--------------------+-------------+
|[30 34 65 31 62 3...|[00 00 00 05 C0 B...|interne.pilo...| 0| 42|2022-06-27 17:28:...| 0|
|[66 62 37 61 31 3...|[00 00 00 05 C0 5...|interne.pilo...| 0| 43|2022-06-30 09:22:...| 0|
|[34 37 35 63 36 3...|[00 00 00 05 C0 5...|interne.pilo...| 0| 44|2022-06-30 17:26:...| 0|
|[62 63 63 39 39 3...|[00 00 00 05 C0 5...|interne.pilo...| 0| 45|2022-07-01 09:58:...| 0|
|[35 33 66 32 30 3...|[00 00 00 05 C0 0...|interne..pilo..| 0| 46|2022-07-05 11:39:...| 0|
|[37 32 30 30 37 3...|[00 00 00 05 C0 0...|interne.pilo...| 0| 47|2022-07-05 11:45:...| 0|
+--------------------+--------------------+--------------------+---------+------+--------------------+-------------+
here after the cast L :
+-------------------------------------------------------------------------------------------------------------+-------------------+---------------------------------------------------------------+---------+------+-----------------------+-------------+
|key |value |topic |partition|offset|timestamp |timestampType|
+-------------------------------------------------------------------------------------------------------------+-------------------+---------------------------------------------------------------+---------+------+-----------------------+-------------+
|[30 34 65 31 62 33 36 38 2D 63 64 66 39 2D 34 37 66 34 2D 38 65 35 34 2D 63 61 34 34 65 39 39 33 35 31 31 39]|�����īVAL
login|interne.pilot|0 |42 |2022-06-27 17:28:21.657|0 |
|[66 62 37 61 31 32 66 34 2D 65 32 32 61 2D 34 35 66 62 2D 38 65 34 65 2D 31 33 39 34 36 62 33 36 64 30 64 66]|����RʫVAL
login |interne.pilot|0 |43 |2022-06-30 09:22:58.05 |0 |
|[34 37 35 63 36 39 37 32 2D 65 37 35 33 2D 34 61 38 64 2D 62 30 61 30 2D 35 31 38 36 63 39 38 62 64 66 63 64]|����RʫVAL
login |interne.pilot|0 |44 |2022-06-30 17:26:40.336|0 |
|[62 63 63 39 39 30 38 32 2D 38 61 34 66 2D 34 37 64 65 2D 39 61 34 64 2D 63 34 32 30 33 32 31 34 30 63 62 33]|����R̫VAL
login |interne.pilot|0 |45 |2022-07-01 09:58:43.243|0 |
|[35 33 66 32 30 35 38 62 2D 64 38 63 65 2D 34 65 66 62 2D 39 61 62 61 2D 63 65 37 66 38 38 31 36 31 37 66 32]|����
ԫVAL
login |interne.pilot|0 |46 |2022-07-05 11:39:15.865|0 |
|[37 32 30 30 37 30 33 39 2D 61 62 62 61 2D 34 65 61 32 2D 61 34 39 63 2D 36 30 32 30 36 62 65 62 36 62 37 38]|����ԫVAL
login |interne.pilot|0 |47 |2022-07-05 11:45:07.092|0 |
+-------------------------------------------------------------------------------------------------------------+-------------------+---------------------------------------------------------------+---------+------+-----------------------+-------------+
key value FULL disply :
FULL KEY VALUE
+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
|key |value |
+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
|[30 34 65 31 62 33 36 38 2D 63 64 66 39 2D 34 37 66 34 2D 38 65 35 34 2D 63 61 34 34 65 39 39 33 35 31 31 39]|[00 00 00 05 C0 B4 02 C4 AB 02 06 56 41 4C 0A 6C 6F 67 69 6E]|
|[66 62 37 61 31 32 66 34 2D 65 32 32 61 2D 34 35 66 62 2D 38 65 34 65 2D 31 33 39 34 36 62 33 36 64 30 64 66]|[00 00 00 05 C0 52 CA AB 02 06 56 41 4C 0A 6C 6F 67 69 6E] |
|[34 37 35 63 36 39 37 32 2D 65 37 35 33 2D 34 61 38 64 2D 62 30 61 30 2D 35 31 38 36 63 39 38 62 64 66 63 64]|[00 00 00 05 C0 52 CA AB 02 06 56 41 4C 0A 6C 6F 67 69 6E] |
|[62 63 63 39 39 30 38 32 2D 38 61 34 66 2D 34 37 64 65 2D 39 61 34 64 2D 63 34 32 30 33 32 31 34 30 63 62 33]|[00 00 00 05 C0 52 CC AB 02 06 56 41 4C 0A 6C 6F 67 69 6E] |
|[35 33 66 32 30 35 38 62 2D 64 38 63 65 2D 34 65 66 62 2D 39 61 62 61 2D 63 65 37 66 38 38 31 36 31 37 66 32]|[00 00 00 05 C0 0A D4 AB 02 06 56 41 4C 0A 6C 6F 67 69 6E] |
|[37 32 30 30 37 30 33 39 2D 61 62 62 61 2D 34 65 61 32 2D 61 34 39 63 2D 36 30 32 30 36 62 65 62 36 62 37 38]|[00 00 00 05 C0 06 D4 AB 02 06 56 41 4C 0A 6C 6F 67 69 6E] |
+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
Everytime I try to use i2cdetect -y 1 its showing me every number I already resetted my Raspberry Pi but that doesnt worked.Is it possible that my Raspberry Pi 3b+ is broken or is it just a bug?
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77
After upgrading my macOsx version to Big Sur(11.1) I am facing weird issue. When I connect the LDAP server I see all information except the DSE root tree not expanding and can not perform any operation for example search/filter. Here its looks like
I got the following error message:
java.lang.NullPointerException (Hexdump: 30 7E 02 01 06 65 07 0A 01 00 04 00 04 00 A0 70 30 6E 04 17 31 2E 33 2E 36 2E 31 2E 34 2E 31 2E 32 36 30 32 37 2E 31 2E 35 2E 34 01 01 FF 04 50 30 4E 04 4C 64 63 3D 70 6F 72 73 63 68 65 2C 64 63 3D 63 6F 6D 3A 30 30 30 30 30 31 37 37 30 61 38 33 62 33 63 37 37 64 32 62 30 30 61 38 30 31 61 61 20 30 30 30 30 30 31 37 37 30 61 38 33 65 33 65 61 37 62 65 30 30 30 61 30 61 36 62 31 3B)
With the following exception stack trace:
org.apache.mina.filter.codec.ProtocolDecoderException: java.lang.NullPointerException (Hexdump: 30 7E 02 01 06 65 07 0A 01 00 04 00 04 00 A0 70 30 6E 04 17 31 2E 33 2E 36 2E 31 2E 34 2E 31 2E 32 36 30 32 37 2E 31 2E 35 2E 34 01 01 FF 04 50 30 4E 04 4C 64 63 3D 70 6F 72 73 63 68 65 2C 64 63 3D 63 6F 6D 3A 30 30 30 30 30 31 37 37 30 61 38 33 62 33 63 37 37 64 32 62 30 30 61 38 30 31 61 61 20 30 30 30 30 30 31 37 37 30 61 38 33 65 33 65 61 37 62 65 30 30 30 61 30 61 36 62 31 3B)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:263)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1128)
at org.apache.mina.filter.ssl.SslHandler.flushMessageReceived(SslHandler.java:330)
at org.apache.mina.filter.ssl.SslFilter.messageReceived(SslFilter.java:552)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1128)
at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:122)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:643)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:539)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$1200(AbstractPollingIoProcessor.java:68)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.process(AbstractPollingIoProcessor.java:1222)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.process(AbstractPollingIoProcessor.java:1211)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:683)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at org.apache.directory.api.ldap.codec.actions.controls.StoreControlValue.action(StoreControlValue.java:81)
at org.apache.directory.api.ldap.codec.actions.controls.StoreControlValue.action(StoreControlValue.java:49)
at org.apache.directory.api.asn1.ber.grammar.AbstractGrammar.executeAction(AbstractGrammar.java:136)
at org.apache.directory.api.asn1.ber.Asn1Decoder.treatTLVDoneState(Asn1Decoder.java:604)
at org.apache.directory.api.asn1.ber.Asn1Decoder.decode(Asn1Decoder.java:740)
at org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolDecoder.decode(LdapProtocolDecoder.java:137)
at org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolDecoder.decode(LdapProtocolDecoder.java:86)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:254)
... 20 more
And here is my session data if you expert might thinks it could be helpful
eclipse.buildId=unknown
java.version=1.8.0_271
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_GB
Framework arguments: /studio-rcp/resources/icons/linux/studio.xpm -keyring /Users/naimrajiv/.eclipse_keyring
Command-line arguments: -os macosx -ws cocoa -arch x86_64 /studio-rcp/resources/icons/linux/studio.xpm -keyring /Users/naimrajiv/.eclipse_keyring
I am stuck more than a day with this and not sure what to do! Any help is much appreciated!
I have upgraded the Apache Studio to version: Version: 2.0.0.v20210213-M16
and it is working just fine
I'm sending the following OSC message to a Behringer X32 mixer:
00000000 2f 6e 6f 64 65 00 00 00 2c 73 00 00 63 6f 6e 66 /node... ,s..conf
00000010 69 67 2f 63 68 6c 69 6e 6b 00 00 00 ig/chlin k...
I'm getting this message back:
00000000 6e 6f 64 65 00 00 00 00 2c 73 00 00 2f 63 6f 6e node.... ,s../con
00000010 66 69 67 2f 63 68 6c 69 6e 6b 20 4f 46 46 20 4f fig/chli nk OFF O
00000020 4e 20 4f 4e 20 4f 4e 20 4f 46 46 20 4f 4e 20 4f N ON ON OFF ON O
00000030 46 46 20 4f 46 46 20 4f 4e 20 4f 4e 20 4f 4e 20 FF OFF O N ON ON
00000040 4f 4e 20 4f 46 46 20 4f 46 46 20 4f 46 46 20 4f ON OFF O FF OFF O
00000050 46 46 0a 00 FF..
It seems that the address in the response is malformed as it does not begin with a preceding slash character /.
According to the OSC 1.0 specification:
An OSC Address Pattern is an OSC-string beginning with the character '/' (forward slash).
Is the packet I'm getting back from the mixer simply an invalid OSC message that I need to deal with, or is there some meaning or convention behind the omission of the slash character?
Found in Patrick-Gilles Maillot's unofficial documentation:
Note/bug: the response from the Server is “node…” and not “/node…” as one could expect. This is not OSC compliant.
I'm new here, so please be gentle.
This question revolves around VB.net / VS2010 / MSMQ 4.0
I'm developing an application that has MSMQ at its heart. There are (currently) 3 separate VB solutions each of which send and receive message to a queue.
I tried using the XMLMessageFormatter and ran into problems with that, plus this is a high performance, time critical app and I understand that XMLMessaegFormatter has a high overhead, so I've switched over to using BinaryMessageFormatter for the messages.
I've established a class (clsTMessage) which provides the structure for the message data and resides in its own .vb file attached to the solution. I realize that the downside of using Binaryformatter is that the exact same class (down to version and all) has to encode and decode the messages and indeed I'm seeing that problem.
So I figured, no problem, I'd just copy clsTmessage.vb to each solution, but that doesn't quite do the trick as the messages encodes with the namespace of the host assemby and therefore the next solution to pick up the message is technically looking for a different class to decode it.
In this example, for instance, you can see that TelemanusWorkbench Version 1.0.0.0 encoded the message using TelemanusWorkbench.clsTMessage.
00 01 00 00 00 FF FF FF .....ÿÿÿ
FF 01 00 00 00 00 00 00 ÿ.......
00 0C 02 00 00 00 49 54 ......IT
65 6C 65 6D 61 6E 75 73 elemanus
57 6F 72 6B 62 65 6E 63 Workbenc
68 2C 20 56 65 72 73 69 h, Versi
6F 6E 3D 31 2E 30 2E 30 on=1.0.0
2E 30 2C 20 43 75 6C 74 .0, Cult
75 72 65 3D 6E 65 75 74 ure=neut
72 61 6C 2C 20 50 75 62 ral, Pub
6C 69 63 4B 65 79 54 6F licKeyTo
6B 65 6E 3D 6E 75 6C 6C ken=null
05 01 00 00 00 1E 54 65 ......Te
6C 65 6D 61 6E 75 73 57 lemanusW
6F 72 6B 62 65 6E 63 68 orkbench
2E 63 6C 73 54 4D 65 73 .clsTMes
73 61 67 65 09 00 00 00 sage....
0E 6E 65 77 4D 65 73 73 .newMess
61 67 65 54 79 70 65 12 ageType.
6E 65 77 50 72 6F 74 6F newProto
63 6F 6C 56 65 72 73 69 colVersi
6F 6E 0D 6E 65 77 49 64 on.newId
65 6E 74 69 66 69 65 72 entifier
0B 6E 65 77 53 6F 75 72 .newSour
63 65 49 50 0D 6E 65 77 ceIP.new
53 6F 75 72 63 65 50 6F SourcePo
72 74 10 6E 65 77 44 65 rt.newDe
73 74 69 6E 61 74 69 6F stinatio
6E 49 50 12 6E 65 77 44 nIP.newD
65 73 74 69 6E 61 74 69 estinati
6F 6E 50 6F 72 74 0C 6E onPort.n
65 77 54 69 6D 65 73 74 ewTimest
61 6D 70 0E 6E 65 77 4D amp.newM
65 73 73 61 67 65 42 6F essageBo
64 79 01 01 01 01 01 01 dy......
01 00 01 0D 02 00 00 00 ........
06 03 00 00 00 03 44 46 ......DF
58 06 04 00 00 00 01 30 X......0
06 05 00 00 00 0C 30 30 ......00
30 30 30 30 30 30 30 30 00000000
30 30 06 06 00 00 00 07 00......
30 2E 30 2E 30 2E 30 06 0.0.0.0.
07 00 00 00 01 30 06 08 .....0..
00 00 00 0B 31 39 32 2E ....192.
31 36 38 2E 31 2E 31 06 168.1.1.
09 00 00 00 04 35 30 30 .....500
30 20 46 FE 12 F9 32 CF 0 Fþ.ù2Ï
88 06 0A 00 00 00 49 70 .....Ip
2C 31 2C 31 32 33 34 35 ,1,12345
36 37 38 39 30 31 32 33 67890123
34 35 36 37 38 39 2C 31 456789,1
32 33 34 35 36 37 38 39 23456789
30 31 32 33 34 35 2C 31 012345,1
2C 69 6E 74 65 72 6E 65 ,interne
74 2C 75 73 65 72 6E 61 t,userna
6D 65 2C 70 61 73 73 77 me,passw
6F 72 64 2C 30 2C 33 30 ord,0,30
0B .
When I pick up the message from another solution/project within the app, it fails to parse the message even though it has an identical copy of clsTMessage it's in namespace TelemanusListener.clsTMessage.
Given that it's generically a bad idea to have multiple copies of the class in different parts of the app anyway, what's the reccomended way to do this ? I've read what MSDN has to say bout this, but it's very thin on how to actually implement it.
Hope I've explained that well enought, if not please ask for more info.
Duncan
Yes. One class library with a public message type needs to be referenced from the two projects.
Bit of warning about automatic properties - don't use them within classes that need to be serialised/deserialised. Each time a class type is compiled into an assembly, the compiler creates a randomly named backing field for each automatic property. This can cause serialisation problems when you deploy the one/same class library compiled at different times with different projects.