在闪亮的应用程序中读取 .txt 文件,其中包含一些文本行后的数据

Read .txt file in shiny app with data after some text lines

我正在开发一个闪亮的应用程序,我需要在其中上传 .txt 数据文件。 但是我拥有的数据文件不仅包含 (x,y) 值,而且一些文本包含在前 14 行中。第15行为空,实际数据从第16行开始

当我在闪亮的应用程序上上传 .txt 文件时,我希望应用程序忽略前 15 行并从第 16 行开始读取数据。

.txt 文件中的数据如下所示:

Profiles of file: D:\Results_CWL\NEXPERIA\PCB ohne Tim\passiver Zyklus\Linien200717_1235535\Default0000.frt
xrange = [0,000000000000 m, 0,180100000000 m]
xsize = 0,180100000000 m
yrange = - 
ysize = -
zrange = [-0,00185947345285 m, 0,00107671234384 m ]
zsize = 0,00293618579669 m
xpoints = 3603
ypoints = 1
- end of header -
Profile 4       
x [m]   z [m]   
x0 = 0,209759995341 y0=0,205091997981   
x1 = 0,389860004187 y1=0,205091997981   

0,000000000000  -0,00123933734030   
5,00000000000E-005  -0,000973215937665  
0,000100000000000   -0,000590819013931  
0,000150000000000   -0,000274342070665  
0,000200000000000   -9,06206436190E-005 
0,000250000000000   -2,28695525823E-005 
0,000300000000000   -4,86363199146E-006 
0,000350000000000   -2,42215123338E-006 
0,000400000000000   1,85044009326E-006  
0,000450000000000   7,64895689370E-006  
0,000500000000000   1,40578438837E-005  
0,000550000000000   1,92459904946E-005  
0,000600000000000   2,32133967265E-005  
0,000650000000000   2,47393222003E-005  
0,000700000000000   2,53496923898E-005  
0,000750000000000   2,50445072950E-005  
0,000800000000000   2,44341371055E-005

我拥有的每个数据文件都是相同的格式。

我尝试在没有任何额外文本的情况下读取数据文件:

data <- reactive({
    req(input$file)
    df <- read.table(file=input$file$datapath[input$file$name==input$Select], sep=input$sep, header = input$header, stringsAsFactors = input$stringAsFactors)
    updateSelectInput(session, inputId = 'xcol', label = 'X Variable',
                      choices = names(df), selected = names(df)[1])
    updateSelectInput(session, inputId = 'ycol', label = 'Y Variable',
                      choices = names(df), selected = names(df))
    return(df)
  })

给我一些建议。

read.table中有一个skip选项,用于指定在开始读取数据之前要跳过的数据文件行数。

read.table(file=input$file$datapath[input$file$name==input$Select], skip = 15, sep = ......)