Running praat script in asp.net web app - asp.net

I am working on a ASP.net web application and I want it to coorperate with a Praat script.
For example I have 2 params in the web app (String text, String filename) and I want to give these two params to the Script and it just write the content of "text" into the file named "filename".
How could I manage this?

I'm not sure if I totally understand the question, but if you are asking how to run a praat script that writes a string to a file from a command line (which I'm guessing might be enough), having a script like this
# Contents of script.praat
form Output to file...
sentence String Your awesome string with spaces
word Filename /path/to/file
endform
# These are the same variable names as in the form
# but with a lowercase initial
string$ > 'filename$'
should do it. You can then run this command from the command line (if you are doing it from asp.net maybe something like this?) as
praat script.praat "some other string with spaces" new_filename.txt

Related

How to add space in Txt file using robotframework

${response14} Get WebElements xpath=// [#id="com_ibm_team_rtc_foundation_web_ui_views_ArtifactListView_4"]
Log ${response14}
${txt1}= Get Text ${response14}
create file ${file2} ${value_1}${txt}${value_11}${txt1}
Log ${txt1}
Here I want to store the value of ${value_1}${txt}${value_11}${txt1} in different lines in text file.
I am able to store all the values in a paragraph, but i don't want that, i need to store in different lines, How do I do this in robot framework
You can insert newlines using \n:
create file ${file2} ${value_1}\n${txt}\n${value_11}\n${txt1}
${CreatingFile} = Create File ${EXECDIR}/data/file.txt
Log to Console

Remove line feed in CSV using Unix script

I have a CSV file and I want to remove the all line feeds (LF or \n) which are all coming in between the double quotes alone.
Can you please provide me an Unix script to perform the above task. I have given the input and expected output below.
Input :
No,Status,Date
1,"Success
Error",1/15/2018
2,"Success
Error
NA",2/15/2018
3,"Success
Error",3/15/2018
Expected output:
No,Status,Date
1,"Success Error",1/15/2018
2,"Success Error NA",2/15/2018
3,"Success Error",3/15/2018
I can't write everything for you, as I am not sure about your system as well as which bash version that is running on it. But here are a couple of suggestions that you might want to consider.
https://www.unix.com/shell-programming-and-scripting/31021-removing-line-breaks-shell-variable.html
https://www.unix.com/shell-programming-and-scripting/19484-remove-line-feeds.html
How to remove carriage return from a string in Bash
https://unix.stackexchange.com/questions/57124/remove-newline-from-unix-variable
Remove line breaks in Bourne Shell from variable
https://unix.stackexchange.com/questions/254644/how-do-i-remove-newline-character-at-the-end-of-file
https://serverfault.com/questions/391360/remove-line-break-using-awk

New line constant

Is there a new line constant that's platform independent in R? I'm used to C# and there's Environment.NewLine which will return \r\n on windows and \n otherwise. Searching turned up nothing, but I assume there has to be something somewhere so that scripts can be platform independent.
Related question: Is there a way to detect the platform a script is running on? This could be useful to know for other reasons (which I haven't thought of yet).
EDIT: Here's why I'm asking. I'm downloading files from an FTP server, but want to get a list of files and only download files that are on the server that don't exist locally. Here's how I'm getting the list of files:
filesonserver <- unlist(strsplit(getURL(basePath, ftp.use.epsv=F, dirlistonly=T), "\n"))
On windows, the files are separated by \r\n. On my mac (where I'm currently working), they're separated by \n. I was looking for a way to make this platform independent. I haven't tried just separating by \n on windows, which might work. There might also be a way to get the list of files as a vector without having to split them, which would avoid this entirely...
The package tryCatchLog has a function determine.platform.NewLine():
https://cran.r-project.org/package=tryCatchLog
https://github.com/aryoda/tryCatchLog/blob/master/R/platform_newline.R
If you consequently use this string instead of hard-coded "\n" your new lines will work platform-independently.
The answer to the initial question appears to be there isn't a new line constant like C# has. But it doesn't matter in my case, as the comments pointed out. It didn't occur to me until after I edited in the details that I probably didn't need to worry about it. Splitting by \n works fine on windows, even though the string containing the files names returned by getURL() is split by \r\n.

Extracting data from a tab-delimited file with JavaScript

I'm trying to extract data from a data file that's tab-delimited (in some parts), and really seems like it's going to be a headache to work out (I reallw wish they could just have CSV-ed it).
Here's the data:
http://www.fededirectory.frb.org/FedACHdir.txt
Here's the format description:
www.fededirectory.frb.org/format_ACH.cfm
I'd like to extract this data and store it in a database with serverside javascript, (ASP). Any ideas?
Your file is not tab delimited... it is position delimited.
To handle the file using javascript, the file must be on the same server and available via HTTP.
If you need to upload the file to some server, the server side language need to extract all the data based on your layout file
In order to extract it... you must for example do something like:
String line = "011000015O0110000150020802000000000FEDERAL RESERVE BANK 1000 PEACHTREE ST N.E. ATLANTA GA303094470866234568111 ";
String routingNumber = line.substring(0,8);
String officeCode = line.substring(8,9);
String servicingNumber = line.substring(9,17);
String typeCode = line.substring(17,18);
...
...
...
String filler = line.substring(151,line.length());
And iterate that code for every line in your file.
In pseudo-code :
for (Line line in File) {
// do the code above
}
Note: Process that file with JavaScript will be painful I recommend to do it in the server side of your application.

ASP Readline non-standard Line Endings

I'm using the ASP Classic ReadLine() function of the File System Object.
All has been working great until someone made their import file on a Mac in TextEdit.
The line endings aren't the same, and ReadLine() reads in the entire file, not just 1 line at a time.
Is there a standard way of handling this? Some sort of page directive, or setting on the File System Object?
I guess that I could read in the entire file, and split on vbLF, then for each item, replace vbCR with "", then process the lines, one at a time, but that seems a bit kludgy.
I have searched all over for a solution to this issue, but the solutions are all along the lines of "don't save the file with Mac[sic] line endings."
Anyone have a better way of dealing with this problem?
There is no way to change the behaviour of ReadLine, it will only recognize CRLF as a line terminator. Hence the only simply solution is the one you have already described.
Edit
Actually there is another library that ought to be available out of the box on an ASP server that might offer some help. That is the ADODB library.
The ADODB.Stream object has a LineSeparator property that can be assigned 10 or 13 to override the default CRLF it would normally use. The documentation is patchy because it doesn't describe how this can be used with ReadText. You can get the ReadText method to return the next line from the stream by passing -2 as its parameter.
Take a look at this example:-
Dim sLine
Dim oStreamIn : Set oStreamIn = CreateObject("ADODB.Stream")
oStreamIn.Type = 2 '' # Text
oStreamIn.Open
oStreamIn.CharSet = "Windows-1252"
oStreamIn.LoadFromFile "C:\temp\test.txt"
oStreamIn.LineSeparator = 10 '' # Linefeed
Do Until oStreamIn.EOS
sLine = oStreamIn.ReadText(-2)
'' # Do stuff with sLine
Loop
oStreamIn.Close
Note that by default the CharSet is unicode so you will need to assign the correct CharSet being used by the file if its not Unicode. I use the word "Unicode" in the sense that the documentation does which actually means UTF-16. One advantage here is that ADODB Stream can handle UTF-8 unlike the Scripting library.
BTW, I thought MACs used a CR for line endings? Its Unix file format that uses LFs isn't it?

Resources