I have a webpage
https://www.google.com/finance/getprices?q=RELIANCE&x=NSE&i=60&p=5d&f=d,c,o,h,l&df=cpct&auto=1&ts=1266701290218
And I'm trying to get the data into a chart.
Any suggestions on how this can be done? Please no code, I just can't get any of it work.
you could use python in this way (writing csv files that are well understood by excel or similar):
#!/bin/python
import urllib2
response = urllib2.urlopen('https://www.google.com/finance/getprices?q=RELIANCE&x=NSE&i=60&p=5d&f=d,c,o,h,l&df=cpct&auto=1&ts=1266701290218')
data = response.read()
import csv
with open('data.csv', 'wb') as csvfile:
writer = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
for line in data.split("\n"):
writer.writerow(list(line.split(",")))
be sure to open it setting the comma as field delimiter.
sorry I skipped the no-code part.
Related
For example, I have a HashSet and want to save it to file like txt or csv and so on.
val slotidSet: util.HashSet[String] = new util.HashSet[String](1)
slotidSet.add("100")
slotidSet.add("105")
slotidSet.add("102")
slotidSet.add("103")
How to save this HashSet into a plain text file?
Thanks in advance.
Something like this should do the work
import java.nio.file.{Files, Paths}
import java.util
Files.write(Paths.get("file.txt"), slotidSet.asScala.mkString(",").getBytes)
Output is
100,102,103,105
Now it's just up to you to choose format, in this case all the elements are just concatenated with ,. In cases where you need to work with files in Scala/Java, Java NIO is a good place to start.
I am opening an existing Excel file using SpreadsheetGear, using the following code:
SpreadsheetGear.IWorkbook xlBook = SpreadsheetGear.Factory.GetWorkbook(fileName, System.Globalization.CultureInfo.CurrentCulture);
xlBook.SaveAs(fileNameCSV, SpreadsheetGear.FileFormat.CSV);
This works, but the saved CSV file contains the wrong sheet.
Can anyone help with a code snippet on how to open an Excel file in SpreadsheetGear, then save only a SPECIFIC sheet to a CSV file.
Please note I am working with SpreadsheetGear and want a solution for that library. Thanks!
The IWorksheet interface includes a SaveAs(...) method for just this purpose:
using SpreadsheetGear;
using System.Globalization;
...
IWorkbook xlBook = Factory.GetWorkbook(fileName, CultureInfo.CurrentCulture);
xlBook.Worksheets["My Sheet"].SaveAs(fileNameCSV, FileFormat.CSV);
I'll also mention that there is also an IRange.SaveAs(...) method if you want to save just a particular range to CSV / UnicodeText (tab-delimited).
I am new to Apache Spark. I ran the sample ALS algorithm code present in the examples folder. I gave a csv file as an input. When I use model.save(path) to save the model, it is stored in gz.parquet file.
When I tried to open this file, I get these errors
Now I want to store the recommendation model generated in a text or csv file for using it outside Spark.
I tried the following function to store the model generated in a file but it was useless:
model.saveAsTextFile("path")
Please suggest me a way to overcome this issue.
Lest say you have trained your model with something like this:
val model = ALS.train(ratings, rank, numIterations, 0.01)
All that you have to do is:
import org.apache.spark.mllib.recommendation.ALS
import org.apache.spark.mllib.recommendation.MatrixFactorizationModel
import org.apache.spark.mllib.recommendation.Rating
// Save
model.save(sc, "yourpath/yourmodel")
// Load Model
val sameModel = MatrixFactorizationModel.load(sc, "yourpath/yourmodel")
As it turns out saveAsTextFile() only works on the slaves.Use collect() to collect the data from the slaves so it can be saved locally on the master. Solution can be found here
I'm trying to modify the values of an attachment to a SOAP Request to correspond to values that I'm getting from a DataSource. I want to do this with a groovy script. I'm looking for a way to reference the attachment file path so I can edit the file itself but I'm having no luck finding that. Is there any way to do this?
I figured it out after looking at the API for a long time
import com.eviware.soapui.impl.wsdl.support.RequestFileAttachment
def xmlFile = testRunner.testCase.getTestStepByName("YOUR TEST STEP NAME").testRequest.getAttachmentAt(0).getUrl()
xmlFile will contain the full path of the attached file. Wanted to post this here in case someone else was looking for a quick way.
I am trying to import a csv file into sugarCRM but on step 2 my data looks like: ;cqà,ý¼nÉBÏÛï÷£ýd$ÕÆóWHkÂQËrÅTyÀÁ
I have just no idea whatsoever what to do. I've tried researching how to import and I am just not seeing anything that helps me with my problem.
Try setting your input file format to UTF-8 and see if that solves the problem. Sounds like a problem with file encoding...