data dump from nseindia to excel - javascript

I need to dump the data from nseindia to the excel.please find the preview of nseindia in below link. From the webpage i need the OPEN HIGH LOW CLOSE and TotalBuyQty, TotalSellQty values in the excel sheet, can anyone help me on the same. I tried normal webpage dump but it is not working.
"http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuoteFO.jsp?underlying=WIPRO&instrument=FUTSTK&expiry=30OCT2014&type=-&strike=-"

Just use Excel to sort.
Thisis what happened when I recorded a sort in Excel.
Range("A1:A18").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Here's a good guide to using the sort function without recording--you can trim it down if you're not using special methods.
sheet("Sheet1").range("Range1").sort key1:=Range("A2"), _
order1:=xlAscending, Header:=xlYes
http://msdn.microsoft.com/en-us/library/office/ff840646(v=office.15).aspx
If you're doing other manipulations to the field after that, you might want to use the AutoFilter as well. Here's a helpful site for that if you're interested:
http://www.ozgrid.com/VBA/autofilter-vba.htm

Related

How to save translated Properties file as right-to-left?

I have a translation of a properties file into Pashto and Dari. Does anyone know how I can save this file to read the content as right-to-left?
I know I am able to toggle to read it right to left in Notepad editor, but I need the raw data to be set to right-to-left.
Thanks in advance!
Stephanie
I dont think that JS has a native way of reading files from right to left.
As a workaround, you could try to create a new string that will be the reversed version of the string you just read.
function reverseWord(x) {
return x.split("").reverse().join("")
}
So, when you're preparing the file to be saved and you want to iterate through all of the lines, add the reverseWord function into the loop.
There may be custom libraries that help with this.

Why is google natural language returning an incorrect beginOffset for analyzed string?

I am using google-cloud/language api to make an #annotate call and analyze entities and sentiments from a csv of comments which I have taken from various online resources.
To begin with, the string I am trying to analyze includes commentId's so I reformat this:
youtubez22htrtb1ymtdlka404t1aokg2kirffb53u3pya0,i just bot a Nostromo... ( ._.)
youtubez22oet0bruejcdf0gacdp431wxg3vb2zxoiov1da,Good Job Baby! MSI Propeller Blade Technology!
youtubez22ri11akra4tfku3acdp432h1qyzap3yy4ziifc,"exactly, i have to deal with that damned brick, and the power supply can't be upgraded because of it, because as far as power supply goes, i have never seen an external one on newegg that has more power then the x51's"
youtubez23ttpsyolztc1ep004t1aokg5zuyqxfqykgyjqs,"I like how people are liking your comment about liking the fact that Sky DID put Deadlox's channel in the description instead of Ryan's. Nice Alienware thing logo thing, btw"
youtubez12zjp5rupbcttvmy220ghf4ctqnerqwa04,"You know, If you actually made this. People would actually buy it."
So that it doesn't include any comment ID's:
I just bot a Nostromo... ( ._.)
Good Job Baby! MSI Propeller Blade Technology!\n"exactly, i have to deal with that damned brick, and the power supply can't be upgraded because of it, because as far as power supply goes, i have never seen an external one on newegg that has more power then the x51's"
"I like how people are liking your comment about liking the fact that Sky DID put Deadlox's channel in the description instead of Ryan's. Nice Alienware thing logo thing, btw"
"You know, If you actually made this. People would actually buy it."
After sending a request for google cloud/language to #annotate the text. I receive a response which includes various substrings sentiments and magnitudes. Each string is also given a beginOffset value, which relates to the strings index in the original string (the string in the request).
{ content: 'i just bot a Nostromo... ( ._.)\nGood Job Baby!',
beginOffset: 0 }
{ content: 'MSI Propeller Blade Technology!\n"exactly, i have to deal with that damned brick, and the power supply can't be upgraded because of it, because as far as power supply goes, i have never seen an external one on newegg that has more power then the x51's"\n"I like how people are liking your comment about liking the fact that Sky DID put Deadlox's channel in the description instead of Ryan's.',
beginOffset: 50 }
{ content: 'Nice Alienware thing logo thing, btw"\n"You know, If you actually made this.',
beginOffset: 462 }
My aim is then to locate the original comment in the original string, which should be simple enough. Something like (originalString[beginOffset]).....
This value is incorrect!
I am assuming that they do not include certain characters, but I have tried a multitude of regexes and nothing seems to work perfectly. Does anyone have any idea about what might be causing the issue???
I know this is an old question but the problem seems to persist even today. I have recently encountered the same issue and resolved it by interpreting Google's offsets as "byte offsets" rather than string offsets in the chosen encoding. Works great. I hope it helps someone.
The following is some C# code but anybody should be able to interpret it and recode in their own favorite language. If we assume that text is actually the sentiment text being analyzed then the following code transforms, Google's offsets into correct offsets.
int TransformOffset(string text, int offset)
{
return Encoding.UTF8.GetString(
Encoding.UTF8.GetBytes(text),
0,
offset)
.Length;
}
This has got something to do with encoding. Play around with one of the encodings or simply use one of the example approaches provided in their github repo:
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/language/api/analyze.py
Key code block:
def get_native_encoding_type():
"""Returns the encoding type that matches Python's native strings."""
if sys.maxunicode == 65535:
return 'UTF16'
else:
return 'UTF32'
This worked for me. It was messing up characters like ' (that is \u2019 in unicode).
You should set the EncodingType on the request.
Example using Java client library and working with UTF-8 encoded texts:
Document doc = Document.newBuilder().setContent(dreamText).setType(Type.PLAIN_TEXT).build();
AnalyzeEntitiesRequest request = AnalyzeEntitiesRequest.newBuilder().setEncodingType(EncodingType.UTF8).setDocument(doc).build();

Jasper Reports - HTML5 Reports(highcharts) - String Replace for Labels

Hoping someone can help. Trying to do a string replace on the labels for my bar chart. So this is built on jasper studio and is a html5 report.
Trying to add the replace function as a javascript function in the report "Advanced Properties". Previously I have successfully set a function here for xAxis.labels.formatter to append labels,
"function(){return this.value.toString().substring(0,5)}"
I have tried to update this for string replace and came up with the below:
"function(){return this.value.toString().str.replace("Section7","W3Schools")}"
This is not working.I dont have much javascript experience and I have tried different formats of the above but no luck so far, any suggestions would be much appreciated?
Got it working. The replace function, works with the below:
Set property name as:
xAxis.labels.formatter
Use as expression:
true
3.Property Value:
"function(){return this.value.replace(\"Section 7\",\"W3Schools\")}"
Or
<hc:chartProperty name="xAxis.labels.formatter">
<hc:propertyExpression><![CDATA["function(){return this.value.replace(\"Section 7\",\"W3Schools\")}"]]></hc:propertyExpression>
</hc:chartProperty>

Extract data from url with JavaScript

EDIT_2: I forgot to specify its for Android app, so i dont think this is any use, i made a new post instead :( Added Android TAG..
EDIT: Im making an Android App
I need help to extract a number from an url, generated by JavaScript!
Site is:
http://www.oddsportal.com/sure-bets/
And the path looks like this:
<span class="logos l60"> </span>
<div class="odds-nowrp" xodd="xzoxfxzox">2.62</div> // <- 2.62 is the numer i need
For full path see this screenshot:
What library would do this best? (I know Jsoup cant do it) I have searched a few like:
HtmlUnit
Java Script Engine
Apache Commons BSF
Rhino
But i cant really make sense of it or find any examples for android which look like my problem
or find any examples for android which look like my problem
You need it for android?
Pretty much any library allowing DOM traversing will allow you to do this providing you know how to find your value.
is this value exactly at the same position in DOM every time?
is it wrapped by an easy to identify element? i.e. with a static ID
are there any other value that look alike in the DOM that you don't want?
Based on that, using JQuery for example, you could select it like this :
$('.table-main td.center > a[href^="/bookmaker"] + div[xodd]')
or this:
$('.table-main tr:nth-child(3) div.odds-nowrp[xodd]')
Use Jquery:
var number = $(".odds-nowrp").text();
you can just use regex if you have the url already in escaped string format
reg = /[A-z\"\>\<=?()0-9 \/]*(\d+.\d+)[A-z\"\>\<=?()0-9 \/]*/
reg.exec(url)[1] // this will return your number
if it's already rendered and the xodd value doesn't change, you could do something like this
document.querySelectorAll('.odds-nowrp[xodd=xzoxfxzox]')[0].innerText

Javascript: Escape " from json string

I've got a bit of a problem. I'm currently working on converting an old system to a newer version. In the old version, data requests were managed by Java applets, which had no problems with the "-char in the data.
Now, though, I'm fetching the data from a database and converting it to a JSON-string using XSLT, and then - with the prototype-function .evalJSON() - making the string into an object.
The XSL then structure the data like this (example) :
{rowsets: [ { rows: [ { "ID":"xxx","OtherProperty":"yyy" } ] } ] }
Which in it self is OK.
Now,when there's some data in the database containing "-characters, the evalJSON() fails, because it destroys the usually well-formatted JSON string, like this:
{rowsets: [ { rows: [ { "ID":"xxx","OtherProperty":"yyy "more" zzz" } ] } ] }
Now, what i want to do, is escape the 'unwanted' "-chars somehow - without having to make some kind of Stored Procedure to du it server-side for me.
I've tried to wrap my head around a RegEx, but I'm not very experienced in that area, and therefore I'm having a really hard time figuring it out.
If it's any help, the character sequences that are sure to be legal are:
[":"] and [","]
and the sequences that are likely to appear, and should be escaped, are:
[\s"], ["\s], [",], [".] (\s indicates a whitespace)
All kinds of help is appreciated, even if it's some SQL that makes it all a lot easier :)
Thanks in advance!
If you're in XSLT land then you're reinventing the wheel. Google up "badgerfish" and see here for a fairly solid implementation. You may of course have other problems getting in the way, but first things first.
I ended up taking a shortcut, using a string-replace template in my XSL to replace the "-characters with \" before returning the JSON to my javascript function, thus not needing to escape anything client-side.
(Used this: http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx)

Categories