batch file extract numbers from text file with little information - string
So This is related to my other two posts. Im dealing with extracting text from a text file and analyzing it and I've run into some problems. For A while I've been using a method that sets all the text between two other strings as a variable, but here is the situation I have. I need to extract the speed (numbers) from the below string: "etc...,query":{"ping":47855},"cmts":...etc. The problem is that the text cmts sometimes changes to something else so really I need to extract all the numbers from this:
,query":{"ping":47855},"
One more thing that makes this difficult is that the characters }," Are all over the file. Thank you for helping me! -Lucas EDG Programmer.
Here's the full file:
{"_id":53291,"ip":"158.69.22.95","domain":"jectile.com","port":25565,"url":"","date_add":1453897770,"status":1,"scan":1,"uptime":99.53,"last_update":1485436105,"geo":{"country":"US","country_name":"United States","city":"Lake Forest"},"info":{"name":" Jectile | jectile.com [1.8-1.11]\n Shoota (Call of Duty) \/ Zambies (Zombie Survival)","type":"FML","version":"1.10","plugins":[],"players":18,"max_players":420,"players_list":[],"map":"world","software":"BungeeCord 1.8.x, 1.9.x, 1.10.x, 1.11.x","avg_player_day":24.458333,"avg_load_day":5.8234,"platform":"MINECRAFT","icon":true},"counter":{"online":47871,"offline":228,"players":{"date":"2017-01-26","total":0},"last_offline":0,"query":{"ping":47855},"cmts":1},"rating":{"main":19.24,"difference":-0.64,"content_up":0.15,"K":0},"last":{"offline":1485415702,"online":1485436105},"chart":{"14:30":14,"14:40":16,"14:50":15,"15:00":18,"15:10":12,"15:20":13,"15:30":9,"15:40":9,"15:50":11,"16:00":12,"16:10":11,"16:20":11,"16:30":18,"16:40":25,"16:50":23,"17:00":27,"17:10":27,"17:20":23,"17:30":24,"17:40":26,"17:50":33,"18:00":31,"18:10":31,"18:20":32,"18:30":37,"18:40":38,"18:50":39,"19:00":38,"19:10":34,"19:20":33,"19:30":40,"19:40":36,"19:50":37,"20:00":38,"20:10":36,"20:20":38,"20:30":37,"20:40":37,"20:50":37,"21:00":34,"21:10":32,"21:20":33,"21:30":33,"21:40":29,"21:50":28,"22:00":26,"22:10":21,"22:20":24,"22:30":29,"22:40":22,"22:50":23,"23:00":27,"23:10":24,"23:20":26,"23:30":25,"23:40":28,"23:50":27,"00:00":32,"00:10":29,"00:20":33,"00:30":32,"00:40":31,"00:50":33,"01:00":40,"01:10":40,"01:20":40,"01:30":41,"01:40":45,"01:50":48,"02:00":43,"02:10":45,"02:20":46,"02:30":46,"02:40":43,"02:50":42,"03:00":39,"03:10":36,"03:20":44,"03:30":34,"03:40":0,"03:50":32,"04:00":35,"04:10":35,"04:20":33,"04:30":43,"04:40":37,"04:50":26,"05:00":31,"05:10":31,"05:20":27,"05:30":25,"05:40":26,"05:50":18,"06:00":13,"06:10":15,"06:20":17,"06:30":18,"06:40":17,"06:50":15,"07:00":16,"07:10":17,"07:20":16,"07:30":16,"07:40":18,"07:50":19,"08:00":14,"08:10":12,"08:20":12,"08:30":13,"08:40":17,"08:50":20,"09:00":18,"09:10":0,"09:20":0,"09:30":27,"09:40":18,"09:50":20,"10:00":15,"10:10":13,"10:20":12,"10:30":10,"10:40":10,"10:50":11,"11:00":13,"11:10":13,"11:20":16,"11:30":19,"11:40":17,"11:50":13,"12:00":10,"12:10":11,"12:20":12,"12:30":16,"12:40":15,"12:50":16,"13:00":14,"13:10":10,"13:20":13,"13:30":16,"13:40":16,"13:50":17,"14:00":20,"14:10":16,"14:20":16},"query":"ping","max_stat":{"max_online":{"date":1470764061,"players":129}},"status_query":"ok"}
By the way, the reason things change is because it looks at info from different servers
Very similar to ther answer I gave you to your first question:
#Echo Off
Set/P var=<some.json
Set var=%var:*:{"ping":=%
Set var=%var:},=&:%
Echo=%var%
Timeout -1
Related
How to change many .sra documents into one fastq document?
I download a series of .sra which belong to one sample from NCBI. I tried to change one sra into fastq, but it is error. My code: $fastq-dump I --split-files ERRXXXXX.sra. And My .sra document is paired. I used $fastq-dump SRR5XXXXX.sra to change another process, and it worked well. Therefore I would like to know how to make many .sra into one .fastq document? Thank you for your kindness.
I don't really understand the whole message, but regarding your specific question "how to make many .sra into one .fastq document", the answer is pretty simple: Generate multiple fastq files from all the sra files you are interested in in the usual way. Concatenate all those fastq files in a single one: cat fastq1.fq fastq2.fq ... fastqN.fq > new_fastq.fq Remove intermediate files if no longer needed The new_fastq.fq file contains all the information from the original sra files. Take care and don't mix first and second ends in the same fastq (unless you know what you are doing, of course).
Loop through to Import Multiple Excel Files and convert each workbook in a file to .dta
I have a file that contains over a 60 excel workbook that I would like to convert each of them to .dta file in stata. I search the net but could not find a decent way of doing it over a loop. I have written a code that needs expert help. In a directory and want to create a loop to save them as .dta files. The code goes as follow forvalues i=1/60{ import excel "D:\Okay\""`i'.xlsx", sheet("Sheet1") firstrow clear save "D:\Okay\""`i'.dta" }
We can't try out your code because it's specific to your computer. Please study https://stackoverflow.com/help/mcve before posting questions. But it's evident that \Okay\""`i'.xlsx" is unlikely to help. As documented many times over -- e.g. [U] 18.3.10 within http://www.stata.com/manuals14/u18.pdf and http://www.stata-journal.com/sjpdf.html?articlenum=pr0042 -- the backslash you want to use under Windows (it's best not to assume everyone recognises your OS) also has a role in Stata as an escape character. That command would be better off ending \Okay/`i'.xlsx" and similar comments apply to the other command lines mentioning files: change the backward slash before a local macro reference to a forward slash, and remove the unnecessary double quotation marks. In fact all this is totally avoidable. Consider cd "D:\Rami Chehab\University Degrees & Courses\PhD in Labour Economics\Data\Data 2016\UNCTAD\Okay" forvalues i=1/60 { import excel `i'.xlsx, sheet("Sheet1") firstrow save `i'.dta } Once you cd to work within a directory or folder, you can keep file names to the bare minimum.
There was plenty of errors I did over there; however, I believe I figured it out. This what you have to code in order to work forvalues date=1/57{ import excel "D:/Rami Chehab/University Degrees & Courses/PhD in Labour Economics/Data/Data 2016/UNCTAD/Okay/`date'.xlsx", sheet("Sheet1") firstrow clear save "D:/Rami Chehab/University Degrees & Courses/PhD in Labour Economics/Data/Data 2016/UNCTAD/Okay/`date'.dta" }
Output other than .txt
I'm looking to build a simple program that will simply modify existing output files from an other program so I don't have to open the program and enter a bunch of data the long way. This program is very specific to my domain and has an extension named .wcc. However, when I change the extension of one of these output files to .txt, I get half gibberish : ÿÿ WPointÿÿ WPolygonÿÿ WQuadrilateralÿÿ WMemberDataÿÿ WLoadÿÿ WLStandardMembersÿÿ WLSavedDesignSettingsÿÿ WLSavedFormatSettingsÿÿ WLSavedViewSettingsÿÿ WLSavedProjectSettingsÿÿ WLSavedSettingsÿÿ WLSavedLoadSettingsÿÿ WLSavedDefaultSettingsÿÿ WLineÿÿ WProductÿÿ WBeamDataÿÿ WColumnDataÿÿ WJoistDataÿÿ WWallStudDataÿÿ WSupportingMemberDataÿÿ WSavedAnalysisSettingsÿÿ WSavedGravityDesignSettingsÿÿ WSavedPreferencesSettingsÿÿ WNotchÿÿ WIJoistÿÿ WFloorCWC37 ÀAE LumberS-P-F No.1/No.2 # À# lumwall.cww ÿÿÿÿ1.2.3.1.Mur_1_EX-D ÿÿÿÿÿÿ B Cÿÿ B C €? 4C 4C Neige #F #F ÈC ÿÿÿ WLStandardMembersÿÿ " There are also musical notes and perpendicular signs which I can't copy paste here. I can sorta read the text, but still not enough to make modifications via txt file. What type of file could this be? Is it even possible to do what I'm trying to do? Thanks!
I am surprised that you are trying to open a .wcc file as a text file (it's contents - as you will see - don't lend themselves to being converted to such a file type); however, the attempt to open the file as a .txt file seems to be specific to your domain. I noticed part of your question is as follows: "What type of file could this be?" You are right in thinking that the .wcc file is a rather obscure file type - we don't think about that file type a lot (or are not conscious of it existing). A .wcc file is a WinCam 2000 Cache file that allows WinCam 2000 movies to be previewed in the slide browser - these were often generated by older WinCam 2000 screen recording and editing programs. Again, the file extension is very rare these days (a Google search only returns ~700 results). But, it appears you have a program that is producing the file, which - as you are saying - "is quite specific to your domain". You may be out of luck with regard to opening them for modification purposes. Supposedly, you can covert .wac files to .wav files, which are much more relevant to today's technology (and definitely alterable from code); however, without knowing the purpose of the file, e.g. what you are trying to do with the file domain-side, I can't say that this will suit your needs. Also, the above comments are "correct": changing a file extension will not convert the file to the file extension type. Typically, converters - like a simple software - are needed to convert files.
Labelling text using Notepad++ or any other tool
I have several .dat, containing information about hotel reviews as below /* <Author> simmotours <Content> review......goes here <Date>Nov 18, 2008 <No. Reader>-1 <No. Helpful>-1 <Overall>4`enter code here` <Value>4 <Rooms>3 <Location>4 <Cleanliness>4 <Check in / front desk>4 <Service>4 <Business service>-1 */ I want to classify the review into two pos and neg , i.e. have two folder pos and neg containing several files with reviews above 3 classified as positive and below 3 classified as negative. How can I quickly and efficiently automate this process?
You could write up a python script to read the overall score. Do this by looping over the the lines using readline() See here. Find the "Overall" Score using some string parsing. Then move the file into the right directory. All very simple things to do in Python, just break it down into steps and search for answers to those steps.
Notepad++ can do replacements with regular expressions. And allows the definition of macros. Use them to convert the file to an XML file. Check out the help file. Then you can read it with any scripting language and do what you want. Alternatively you could change the file to a form where you can load it into Excel and do the analysis there.
Perl: Find duplicate in excel/csv file and write an output file with them
First of all I am a completely newbie (for now) with Perl, and I would like to ask you a quick advice. I have to deal with a some lists of journals and publishers in different Excel/CSV files. I would like to find a way to cross the data in order to have the list of the titles & publishers in common between two files, and a list with the publisher and the number of journal published. I would like to ask you if it is possible to do it with Perl (it should be the best method for what I understood, but I would like a confirmation!), and how advance it is. Sorry for the strange request but I am writing my thesis and I would not like to spend time on something and discover that is not possible! Thanks!
Yes. To parse a CSV file: Text::CSV_XS To parse an Excel file: Spreadsheet::ParseExcel To find the common elements of two lists: my %list1 = map { $_ => 1 } #list1; my #common = grep $list1{$_}, #list2;