# Combining data of different GCNs in a single file

**URL:** <https://discourse.julialang.org/t/combining-data-of-different-gcns-in-a-single-file/102013>\
**Category:** Data\
**Tags:** strings, data, loops, dataframes\
**Created:** [July 24, 2023, 12:18pm UTC](https://discourse.julialang.org/t/combining-data-of-different-gcns-in-a-single-file/102013 "2023-07-24T12:18:32Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![raman\_kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raman_kumar/32/26782_2.png) [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Post date:** [August 1, 2023, 10:33am UTC](https://discourse.julialang.org/t/combining-data-of-different-gcns-in-a-single-file/102013/22 "2023-08-01T10:33:42Z")

</div>

Still it is not renaming `Tmid-T0` and `Limit` columns. 😟

> **Look code**
>
> ```julia
> using HTTP , CSV, DataFrames
> function doanalysis()
> dfg=nothing
> for x in 34000:34146
> print("\r peeking at GCN $x ")
> try
> url = "https://gcn.nasa.gov/circulars/$x/raw"
> resp = HTTP.get(url) 
> status=resp.status
> print(" ",status," "); 
> if status == 404 ; println("status=",status); continue; end          
> txt = String(resp.body)
> grb_rexp=r"GRB ?\d{6}([A-G]|(\.\d{2}))?"
> m=match(grb_rexp,txt)
> grb="nogrb"
> if occursin(grb_rexp,txt)
> print(m.match)
> grb=m.match
> end
> function dframe()
> df.GCN=[x for i in 1:nrow(df)]
> df.GRB=[grb for i in 1:nrow(df)]
> if isnothing(dfg) 
> dfg=df
> else
> dfg=vcat(dfg,df,cols=:union)
> end # if x is first
> end # dframe
> 
> if occursin("V. Lipunov", txt)
> println(" MASTER report")                                
> he=first(findfirst(r"^Tmid"im,txt))
> lr=first(findnext("\nFilter",txt,he))-1
> cltxt=txt[he:lr]                                 
> df=CSV.read(IOBuffer(cltxt), DataFrame, delim='|', skipto=3) 
> if "Limit" in names(df); rename!(df, "Limit" => "Mag"); end  
> if "Filt." in names(df); rename!(df, "Filt." => "Filter"); end 
> if "Tmid-T0" in names(df); rename!(df, "Tmid-T0" => "Time"); end
> #rename!(df, "Filt." => "Filter", "Tmid-T0" => "Time")        
> dframe()
> elseif occursin("report on behalf of the Swift/UVOT team",txt)
> println(" SWIFT/UVOT report")
> hb,he=findfirst(r"^Filter"im,txt)
> lr,_=findnext("\n\nThe",txt,he)
> cltxt=replace(txt[hb:lr], " +/- "=>s"\t", r" +(\w)"=>s"\t\1" ,r" +(&gt;)"=>s"\t",r"\+/?- ?"=>s"\t",">"=>s"\t")
> df=CSV.read(IOBuffer(cltxt), DataFrame, delim='\t')
> if "Column6" in names(df); rename!(df, :Column6 => :Mag_err); end
> df.Time = (df."T_start(s)" .+ df."T_stop(s)") ./2
> dframe()
> end # if occursin
> catch e
> println("error ")
> #rethrow()
> end # trycatch
> end # for loop
> println()
> if !isnothing(dfg)
> CSV.write("data-all.csv",dfg)
> else
> @info "no dfg to write"
> end # !isnothing
> end # function doanalysis
> doanalysis()
> 
> ```

but below code works if i provide renaming for [every column](https://discourse.julialang.org/t/how-to-rename-several-columns-of-julia-dataframe/92232/3).

```julia
 rename!(df,["Time","Date Time","Telescope","Coord (J2000)","Filter","Exp(s)","Mag","Comment"])      

```

---

_[View the full topic](https://discourse.julialang.org/t/combining-data-of-different-gcns-in-a-single-file/102013)._
