GithubHelp home page GithubHelp logo

Comments (4)

kMutagene avatar kMutagene commented on July 23, 2024

There is no code executed from this library to get the worksheet (also true for #36 ) - it is just FsWorkbook.tryGetWorksheetByName and getWorksheetByName guarded with a try ... with. So this looks like a FsSpreadsheet issue to me.

let getStudyMetadataSheet (useLastSheetOnIncorrectName: bool) study =
try
FsWorkbook.tryGetWorksheetByName "Study" study
|> Option.defaultValue (FsWorkbook.getWorksheetByName "isa_study" study)
with _ ->
if useLastSheetOnIncorrectName then
FsWorkbook.getWorksheets study
|> Seq.last
else
failwith "No worksheet named 'Study' or 'isa_study' found in the workbook"
let getAssayMetadataSheet (useLastSheetOnIncorrectName: bool) assay =
try
FsWorkbook.tryGetWorksheetByName "Assay" assay
|> Option.defaultValue (FsWorkbook.getWorksheetByName "isa_assay" assay)
with _ ->
if useLastSheetOnIncorrectName then
FsWorkbook.getWorksheets assay
|> Seq.last
else
failwith "No worksheet named 'Assay' or 'isa_assay' found in the workbook"

We should definitely add integration tests for these functions though.

from arctokenization.

kMutagene avatar kMutagene commented on July 23, 2024

On another note, possible workheet names should all be defined by structural ontology

from arctokenization.

omaus avatar omaus commented on July 23, 2024

Hm...

Try this.

#r "nuget: FsSpreadsheet"
#r "nuget: FsSpreadsheet.ExcelIO"


open FsSpreadsheet
open FsSpreadsheet.ExcelIO


let wb = FsWorkbook.fromXlsxFile @"C:\Users\<you>\Downloads\isa.study.xlsx"

FsWorkbook.tryGetWorksheetByName "Study" wb 

Le output:

val it: FsWorksheet option =
  Some
    FsSpreadsheet.FsWorksheet
      {CellCollection = FsSpreadsheet.FsCellsCollection;
       Columns = seq
                   [seq
                      [A1 : STUDY METADATA | String;
                       A2 : Study Identifier | String;
                       A3 : Study Title | String;
                       A4 : Study Description | String; ...];
                    seq
                      [B2 : experiment1_material | String;
                       B3 : Prototype for experimental data | String;
                       B4 : In this a devised study to have an exemplary experimental material description. | String;
                       B5 :  | String; ...]];
       Name = "Study";
       Rows = seq
                [seq [A1 : STUDY METADATA | String];
                 seq
                   [A2 : Study Identifier | String;
                    B2 : experiment1_material | String];
                 seq
                   [A3 : Study Title | String;
                    B3 : Prototype for experimental data | String];
                 seq
                   [A4 : Study Description | String;
                    B4 : In this a devised study to have an exemplary experimental material description. | String];
                 ...];
       Tables = seq [];}

Then try this:

FsWorkbook.tryGetWorksheetByName "Study" wb 
|> Option.defaultValue (FsWorkbook.getWorksheetByName "isa_study" wb)

outputs:

> FsWorkbook.tryGetWorksheetByName "Study" wb 
- |> Option.defaultValue (FsWorkbook.getWorksheetByName "isa_study" wb);;
System.Exception: FsWorksheet with name isa_study is not present in the FsWorkbook.
   at FsSpreadsheet.FsWorkbook.GetWorksheetByName(String sheetName)
   at <StartupCode$FSI_0012>.$FSI_0012.main@() in C:\Users\revil\Untitled-1:line 13
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error

The fuck is this?! 😳

from arctokenization.

omaus avatar omaus commented on July 23, 2024

Ahh, nvm.

It tries to evaluate FsWorkbook.getWorksheetByName "isa_study" wb, no matter if FsWorkbook.tryGetWorksheetByName "Study" wb is Some or None.

So, care!: Option.defaultValue is not like && or ||. It doesn't stop evaluating just because it's Some.

from arctokenization.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.