Within my sidebar panel of my ui.R I have:
selectizeInput(
'dv', 'DV:', choices = names(data)
),
I have a file input box that I want to read the users .csv file and extract the column names from. The data the user uploads is read correctly (I have it displayed as a data table) and saved as "data".
The selectize box remains empty however. I know I need to somehow save "data" in a way that saves it so that the ui can read it, I just cannot figure out how to do that. Here is the code I have to read the file and display the table that works perfectly, but can someone explain how to save this so I can call names(data) in my ui selectisize?
output$subjects <- renderDataTable({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
data <- read.csv(inFile$datapath)})
Thank you so much!
Related
In vue-filepond, I can drag or select files and they process fine, but I want to be able to submit user entered data along with each image. For example, they may want to tag the image or enter a title, etc..
I can't find any documentation on how to do this?
You can use the file.setMetadata method (https://pqina.nl/filepond/docs/patterns/api/file/#methods) to add metadata to each file, each upload will contain a File object and a JSON object (the JSON object will contain the metadata).
I am reading in a CSV file with Ruby and it works fine except if there are blank rows at the start. It seems to skip the blank lines and go straight to a line with content. I want to read the blank lines as I need to count the row numbers.
I use this function, which works fine except for skipping the blank rows:
CSV.foreach(params[:file].tempfile, headers: false, :encoding => 'ISO-8859-1') do |row|
I have a user input which dictates the starting row to read in, so I need to count down each row until I reach the desired row to read. I really do not want to tell the user to edit the csv file to make sure rows are not blank.
UPDATE:
OK, my question turned out to be a red herring. The actual problem was that I had an Excel file with blank lines at the start. When I saved as a CSV file from within Excel, the blank lines were being removed from the saved CSV file but the Excel view of the file, i.e. filename.csv, still showed the blank lines present. I only discovered this by re-opening the file in Excel or a text editor. (All posted comments helped give me the clues to find this).
So ... now I have a new problem ... why does Excel remove blank rows when saving as CSV?
OK, my question turned out to be a red herring. The actual problem was that I had an Excel file with blank lines at the start. When I saved as a CSV file from within Excel, the blank lines were being removed from the saved CSV file but the Excel view of the file, i.e. filename.csv, still showed the blank lines present. I only discovered this by re-opening the file in Excel or a text editor.
I have a table in an InDesign document. I will to add an inline image to the first cell.
var myPics = File("/c/test.png"),
myDoc = app.activeDocument,
myPage = myDoc.pages[0],
myTable = myDoc.stories.everyItem().tables[0],
myCell = myTable.cells[0];
myCell.contents = myPics;
I expect there should be an image put into the cell, but the file address is filled instead. What should I do?
The contents of text objects in InDesign are not exact equivalents of actual formatted native InDesign text; they are always cast to and from simple Javascript text strings. Reading the contents discards all of InDesign's text attributes (for instance, text formatting, hyperlinks, bookmarks, XML markers, and all meta-objects such as images); and writing contents fills the destination with plain text, formatted with the default formatting of the text container at the location you place the text.
You cannot store a PNG file "in" a Javascript variable; not as a File object (it will not be parsed into the actual file's contents), and not as 'an image' (the contents will be treated as a text string, not 'meaning' anything).
The proper way is to use place, which can work on an InDesign document as a whole, in which case the file will be imported directly 'on' a page, or using a text location through a valid property such as its insertionPoints:
var myPics = File("/c/test.png"),
myDoc = app.activeDocument,
myPage = myDoc.pages[0],
myTable = myDoc.stories.everyItem().tables[0],
myCell = myTable.cells[0];
myCell.insertionPoints[0].place(myPics);
If you want make sure the contents of myCell is empty before placing, you can add
if (myCell.texts[0].length > 0)
myCell.texts[0].remove();
A warning on your use of everyItem(): when used this way, it is a live collection. A collection acts like an array, except that each element of the collection is 'seen' as the one and only object. Thus, you can do something like
myTable.cells.everyItem().contents = "hello!";
and the text will appear in every single cell, because of the everyItem() command. But since you already created a collection of tables -- myDoc.stories.everyItem().tables[0] will be a list of "the" first table in all of the current document's stories -- you will find, to your surprise, that all of these will suddenly contain hello as well.
You can see this if you place a copy of your current text frame on the same page and run my version of your script again. You will find it inserts the same image in both the tables!
Presumably you want to insert the image only once, in the first table, in the first story, on the first page. That would then be
myTable = myPage.stories[0].tables[0];
this seem a simple question but I can get only the real value of cell, not the display text because I use tableColumn.setCellFactory to change the display text of cell (use a method to convert from real value to my disired text), so the cell will have 2 values: display text and real value. I can re-convert but it's a silly solution :(
cell = t.getColumns().get(col).getCellData(row);
You can't access the renderer directly. Among the reasons is that you'd have to access the VirtualFlow that contains the display nodes. However, I give you an answer to the detail information you posted:
In order to make an agnostic export functionality (to CSV, XLS etc.)
it would be very convenient to request cell text, rather than data,
from a table view. Is that possible?
For any kind of export use a converter.
You never know what target format your users have. Your users could have different number format settings in your JavaFX application than what they have in Excel. Using Excel you need to get your JavaFX model data and set Excel's model data. Don't export using the view data and expect importing in Excel view would work, you'll run into problems.
Same for CSV. If you are e. g. on german localization, a 2 decimals number will look like 123,45 in your table instead of 123.45. So when you export the table's view data, you'll break your CSV format.
You won't get around exporting your model data via a proper converter.
You can use the getItems() method to access the model of the Table. Based on the row id you can get the DataModel for that row.
tblSampleTable.getItems().get(rowId);
So you have a reference to the DataModel, that means you can access all the data (actual data)
If you need to get the display text of TableView you can do this:
public void showAllText(TableView<?> tv){
for (Node r: tv.lookupAll(".table-row-cell")) {
for (Node c: r.lookupAll(".table-cell")) {
TableCell<?, ?> tc=(TableCell<?, ?>) c;
System.out.print(tc.getText()+" \t ");
}
System.out.println("");
}
}
Good luck.
Is there any way to read the contents of a webpage once it gets loaded completely. I have to read the prices from a site and need to store them in my database. But the prices in the site loads through ajax. As a result , I just get "Loading" instead of values. Is there any way to extract the contents once the file get loaded completely.
Waiting for reply...
Can't you read the contents from the file that is requested by that site?